I'm binding a ListView
to an IQueryable<IGrouping<>>
generated using Linq-to-SQL like so:
var lineChanges = dcOJ.LineAuthoriserChanges.GroupBy(g => g.tbl_line)
.OrderBy(ord => ord.Key.tbl_journal.RefNo);
lvLineAuthoriserChanges.DataSource = lineChanges;
lvLineAuthoriserChanges.DataBind();
In the markup, I try to reference the Key
property of the IGrouping<>
object:
<td rowspan="2"><%# Eval("Key.tbl_journal.RefNo") %></td>
However, I get the error:
DataBinding: 'System.Data.Linq.SqlClient.ObjectReaderCompiler+Group`2[[Online.LinqToSQL.tbl_line, Online, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Online.LinqToSQL.LineAuthoriserChange, Online, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a property with the name 'Key'.
I can cast the data item and display the value that way but it seems so unsatisfactory.
<%# ((IGrouping<tbl_line, LineAuthoriserChange>)Container.DataItem).Key.tbl_journal.RefNo %>
Does anyone have any ideas what is going on? It seems odd that the complaint should be about missing property on a typed object.