Thursday, October 25, 2012

Bind data to gridview using LINQ in

In previous posts we have seen how to bind the data to gridview and bind data to dropdown in gridview in this post i will given how to bind and filter the data then bind to grid view using LINQ in i have placed a button and grid view then get the orders data with linq query.
//add name spaces
//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();
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;

No comments: