How can I populate a drop down list within a repeater for the iEnumerable participants?
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>
The error occurs at asp:DrowDownList, stating that VB$AnonymousType_1 does not contain a property with the name 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'.
I have attempted to convert the participants with .ToList, and .AsEnumerable, but still getting errors with that.
Any help would be appreciated.
Thanks!
Of course this falls as the second list, Actions doesn’t have ParticipantName property. The property is within items of the third list. So you could change the code as follows:
Hope that helps.