DataSource (mojego przemiennika) to Dictionary<string, IList<User>>
Chciałbym, aby wzmacniacz wyświetlał wszystkie Klucze mojego słownika i chciałbym, aby mój ListView używał wszystkich Danych w Wartości mojego słownika.
Powinien wygenerować jakiś kontener, kontener ma nazwę (klucz słownika) i ma wiele wartości (wartość słownika powiązanego z kluczem).
Na razie mam coś takiego:
<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>
Jak mogę powiązać mój ListView?
Odpowiedzi:
0 dla odpowiedzi № 1znacznie łatwiej jest wyświetlić klucz w ItemTemplate zewnętrznej kontroli Repeatera. Możesz zrobić jak poniżej. Nie masz pewności, jak wyświetlić klucz w wewnętrznym pojemniku (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>