Wednesday, 3 December 2014

Data Table manipulation techniques 1

Data Table manipulation techniques :

Hai friend today I am going to explain about Data Table manipulation techniques in asp.net ..it is one of the techinques used to take the query from the dataset..
For example if u have reterive data from table using dataset then use data in front end don’t go for other sql query for database

        
  protected void Page_Load(object sender, EventArgs e)
        {
            grddata.DataSource = registertable();
            grddata.DataBind();
          
        }

        public DataTable registertable()
        {
            dt = new DataTable();
            dt.Columns.Add("sno");
            dt.Columns.Add("name");
            dt.Columns.Add("salary");
            dt.Columns.Add("designation");
            dt.Rows.Add("1001", "sharth", "100000", "dotnet");
            dt.Rows.Add("1002", "ramesh", "40000", "java");
            dt.Rows.Add("1003", "rakesh", "100000", "testing");
            dt.Rows.Add("1004", "shiva", "100000", "java");

          
                DataTable dt2 = new DataTable();

                   dt2 = dt.Select("salary=100000").CopyToDataTable();

                   ViewState["datanew"] = dt2;
                   grddata2.DataSource = dt;
                   grddata2.DataBind();
                

                   return dt2;
          

           



              

        }

0 comments:

Post a Comment