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?
ToList(). You can bind anIEnumerableto a GridView. Andproin your code is anIQueryablewhich is anIEnumerable. The exception makes no sense in the context of the code you have shown above. On which line do you get exactly this exception when you debug?