views:

202

answers:

2

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 that each have a list of Usernames.. If this is a correct approach how can I do this or what is a better way?

A: 

You can do it this way. You can also use:

  • Labels
  • Span runat="server" and add them programmatically
  • (ghetto) string.replace
tsilb
+1  A: 

If you have a list of titles, that each have their 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 the rptUsers during the ItemDataBound event of rptTitle...

Max Schilling