Can I embed templates in the Web User Control?
I want to do something like this:
<MyTemplate>
<span><%# Container.Title %></span>
<MySubTemplate>
<span><%# Container.Username %></span>
</MySubTemplate>
</MyTemplate>
Assuming I have a list of titles, each with a list of usernames. If this is the correct approach, how can I do it, or which is better?
0
source to share
2 answers
If you have a list of names, each has its own list of UserNames, it seems like you want to do something with nested repeaters (or other controls), not templates ...
<asp:Repeater ID="rptTitle" runat="server" >
<ItemTemplate>
<%# Eval("Title") %>
<asp:Repeater ID="rptUsers" runat="server" >
<ItemTemplate>
<%# Eval("UserName") %>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
And then bind rptUsers during the ItemDataBound rptTitle event ...
+1
source to share