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
Greg
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
Max schilling
source
to share
You can do it like this. You can also use:
- Stickers
- Span runat = "server" and add them programmatically
- (ghetto) string.replace
0
tsilb
source
to share