How to bind gridview using linq/Entity Framework?
Posted
by
Kay
on Stack Overflow
See other posts from Stack Overflow
or by Kay
Published on 2011-05-03T11:52:14Z
Indexed on
2011/06/29
16:22 UTC
Read the original article
Hit count: 302
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?
© Stack Overflow or respective owner