SqlDataAdapter adp = new SqlDataAdapter("select * from Products", "server=.;database=dbname;uid=sa");
DataSet ds = new DataSet();
adp.Fill(tb);
//Creating DataView
DataView dv = ds.Tables[0].DefaultView;
//Filtering Data in DataView
dv.RowFilter = "CategoryID=1";
//converting DataView back to DataTable using Table Property of DataView Class
DataTable tb = dv.Table;
// or usefToTable() method if you have done some sorting or filtering with DataView
DataTable tb1 = dv.ToTable();
GridView1.DataSource = tb;
GridView1.DataBind();
DataSet ds = new DataSet();
adp.Fill(tb);
//Creating DataView
DataView dv = ds.Tables[0].DefaultView;
//Filtering Data in DataView
dv.RowFilter = "CategoryID=1";
//converting DataView back to DataTable using Table Property of DataView Class
DataTable tb = dv.Table;
// or usefToTable() method if you have done some sorting or filtering with DataView
DataTable tb1 = dv.ToTable();
GridView1.DataSource = tb;
GridView1.DataBind();
No comments:
Post a Comment