In previous posts we have seen how to bind the data to gridview and bind data to dropdown in gridview in asp.net.In this post i will given how to bind and filter the data then bind to grid view using LINQ in Asp.net.Here i have placed a button and grid view then get the orders data with linq query.
//add name spaces System.Data.SqlClient; System.Linq; //button click_event SqlConnection con=new SqlConnection("User id=sa;password=;Databse=test;server=localhost"); SqlDataAdapet ad=new SqlDataAdapater("Select * from products",con); Dataset dslq=new Dataset(); da.Fill(ds,"d"); DataTable dtlq=dslq.Tables("d"); Enumerable <DataRow> Edr=dtlq.AsEnumerable(); Queryable <DataRow> EQ=dtlq.AsQueryable(); EQ=From i in EQ where i["ordername"].Tostring=="Computer" select i; EQ=From i in EQ where int.parse(i["orderid"].Tostring())<5 select i; GvOrder.DataSourcec=QE.CopyToDataTable();
No comments:
Post a Comment