Hi
Long back I too faced the same problem
Instead of doing the any kind of casting inside your LINQ Query, do the casting first and assign it into any variable and use that variable inside the LINQ Query.
So your code need to be altered like this
DateTime dtStart = Convert.ToDateTime(stDate);
DateTime dtEnd = Convert.ToDateTime(enDate);
using (IERPEntities iERPEntities = new IERPEntities())
{
var result = from res in iERPEntities.Item_General
where res.Date <= dtStart
&& res.Date >= dtEnd
&& res.Name.Contains(txtSelectItemName.Text)
select res;
GridView2.DataSource = result;
GridView2.DataBind();
}
I hope it will give you some idea regarding the problem.