How to bind gridview using linq/Entity Framework?
- by Kay
I need to bind GridView, I am using this code:
ProductDBEntities db = new ProductPDBEntities();
var pro = from u in db.Products where u.PID == 1 select u;
if (pro != null)
{
GridView1.DataSource = pro;
GridView1.DataBind();
}
and getting this error.
System.InvalidOperationException:
Sequence contains more than one
element
Can somebody please tell me what am I doin wrong?