I just using a simple LINQ query having group by clause and trying to bind its result set to GridView. My LINQ query looks like
var expData = from c in WebDB.Tra
EDIT This ignores the "" in your linq statement
Look at the attribute on your asp.net GridView(aspx code): DataKeyField="" is pointing to a column name that does not exist in your linq query
<asp:GridView AutoGenerateColumns="true" DataKeyField="Key"/>
I had your problem either , I wrote like this . I hope this work for you :
var expData = from c in WebDB.TransTable
group c by c.enterdate into g
select new {EnterDate = g.Key};
expData
is a string
as you've put the LINQ query inside quotation marks.
var expData = "from c in WebDB.TransTable
group c by c.enterdate into g
select g;"
System.String
does not have a property called Key
, hence the error.
If you remove the quotation marks it should all work fine.