Assign Sql Database to Gridview Usin LINQ in C#

LINQ to Entities does not recognize the method System.String ToString() method, and this method cannot be translated into a store expression.


LINQ to Entities does not recognize the method System.String ToString() method, and this method cannot be translated into a store expression.
 
 
Exception
In following code snippet, a LINQ to SQL query is executed on the records returned from the Entity Framework.
CustomersEntities entities = new CustomersEntities();
Gridview1.DataSource = (from p in entities.Customers
                                    select new SelectListItem
                                    {
                                        Text = p.Name,
                                        Value = p.CustomerId.ToString()
                                    }).ToList();

Gridview1.DataBind();
 

Comments

Popular posts from this blog

Drag and Drop multiple File upload using jQuery AJAX in ASP.Net using C# and VB.Net

jQuery dynamic menu from database in asp.net

Automatically send Birthday email using C#.Net