2012-11-19 5 views
0

iEnumerable 참가자의 리피터 안에 드롭 다운 목록을 채우려면 어떻게해야합니까?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 : VB $ AnonymousType_1이 이름 ParticipantName와 속성을 포함하지 않는다는, DrowDownList :

<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에서 발생한다.

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,하지만 여전히 그와 오류를 받고있다.

어떤 도움

주시면 감사하겠습니다.

감사합니다.

답변

0

물론 두 번째 목록에 해당합니다. 작업에는 ParticipantName 속성이 없습니다. 이 속성은 세 번째 목록의 항목 내에 있습니다. 따라서 다음과 같이 코드를 변경할 수 있습니다.

<asp:DropDownList ID="dd_participants" runat="server" DataSource='<%# Eval("Participants") %>' DataTextField="ParticipantName" DataValueField="ParticipantId"> 
       </asp:DropDownList> 

희망이 있습니다.

+0

예! 그건 의미가 있습니다! 고맙습니다! –

관련 문제