如何在 iEnumerable 参与者的中继器中填充下拉列表?
Dim ac = pl.pages _
.Where(Function(p) p.urlName = "2012Basketball" And p.organization.urlName = "CopleyHS") _
.SelectMany(Function(p) p.actions) _
.GroupBy(Function(s) s.eventId) _
.[Select](Function(g) New With { _
Key .EventId = g.Key, _
Key .EventName = g.FirstOrDefault().event.name, _
Key .Actions = g.[Select](Function(s) New With { _
Key .ActionId = s.id, _
Key .ActionName = s.name, _
Key .Participants = s.event.participants.[Select](Function(k) New With { _
Key .ParticipantName = k.name, _
Key .ParticipantId = k.id _
}) _
}) _
})
rep_Events.DataSource = ac
rep_Events.DataBind()
.aspx:
<asp:Repeater ID="rep_Events" runat="server">
<ItemTemplate>
<b><%#Eval("EventName")%></b>
<asp:Repeater ID="rep_Actions" runat="server" Datasource='<%#Eval("Actions") %>'>
<ItemTemplate>
<blockquote>
<%#Eval("ActionName")%> <br />
<asp:DropDownList ID="dd_participants" runat="server" DataSource='<%# Eval("Participants") %>' DataTextField='<%# Eval("ParticipantName") %>' DataValueField='<%#Eval("ParticipantId")%>'>
</asp:DropDownList>
</blockquote>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
错误发生在 asp:DrowDownList,指出 VB$AnonymousType_1 不包含名为 ParticipantName 的属性。
DataBinding: 'VB$AnonymousType_1`3[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.IEnumerable`1[[VB$AnonymousType_2`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], App_Web_2earclkn, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' does not contain a property with the name 'ParticipantName'.
我尝试使用 .ToList 和 .AsEnumerable 转换参与者,但仍然出现错误。
任何帮助,将不胜感激。
谢谢!