views:

28

answers:

1

The DataSource (of my repeater) is a Dictionary<string, IList<User>>

I would like the repeater to show all the Key of my dictionary and I would like my ListView to use all the Data inside the Value of my dictionary.

It's should generated some kind of container. Container got a name (key of the dictionary) and got many values (Value of the dictionary associated with the key).

For now, I got something like that :

<asp:Repeater ID="rpt" runat="server">
  <ItemTemplate>
   <asp:ListView ID="lv" runat="server">
    <LayoutTemplate>
     <table>
      <tr>
       <td colspan="2">
           GroupName (should be take from the key of the dictionary)
       </td>
      </tr>
      <tr id="trConfigurationHeader">
       <th>Name</th>
       <th>Description</th>
      </tr>
      <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
     </table>
    </LayoutTemplate>
    <ItemTemplate>
     <tr>
      <td><%#Eval("Name")%></td>
      <td><%#Eval("Description")%></td>
     </tr>
    </ItemTemplate>
   </asp:ListView>
  </ItemTemplate>
 </asp:Repeater>

How can I bind my ListView ?

A: 

it is much easier to display the Key in the ItemTemplate of the outer Repeater Control. You can do as below.Not exactly sure how to display Key in inner container (ListView)

  <asp:Repeater ID="rpt" runat="server" >
  <ItemTemplate>Group :
  <asp:Label ID="dd" runat="server" Text='<%# Eval("Key") %>' ></asp:Label>
   <asp:ListView ID="lv" runat="server" DataSource='<%# Eval("Value") %>'  >
    <LayoutTemplate>
     <table>

      </tr>
      <tr id="trConfigurationHeader">
       <th>Name</th>
       <th>Description</th>
      </tr>
      <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
     </table>
    </LayoutTemplate>
    <ItemTemplate>
     <tr>
      <td><%#Eval("Name")%></td>
      <td><%#Eval("Description")%></td>
     </tr>
    </ItemTemplate>
   </asp:ListView>
  </ItemTemplate>
josephj1989

related questions