Asp.Net - ListView inside a Repeater
The DataSource (of my repeater) is a Dictionary<string, IList<User>>
I would 开发者_JAVA技巧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 ?
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>
精彩评论