【发布时间】:2014-08-19 12:16:41
【问题描述】:
我正在尝试使用转发器控件显示 Linq 分组结果。我的 ASPx 代码如下:
<asp:Repeater runat="server" ItemType="System.Linq.IGrouping`2[System.Int32, myProject.Student]">
<ItemTemplate>
Age: <%# Item.Key %> / Count <%# Item.Count() %>
//Maybe another repeater for each record in the group
</ItemTemplate>
</asp:Repeater>
Select 方法是:
public System.Linq.IGrouping<Int32, myProject.Student> Repeater_StudentByAge_GetData()
{
return new context().Student.GroupBy(x=>x.Age);
}
Visual Studio IntelliSense 与我的 ItemType 声明配合良好,但在运行时收到以下错误:
Could not load type'System.Linq.IGrouping2[System.Int32, myProject.Student]'.`
我可以知道什么是正确的方法吗?
【问题讨论】:
标签: asp.net linq webforms repeater