Irakli Lekishvili
Irakli Lekishvili

Reputation: 34158

Html table layout when binding with asp.net C# repeater

I have asp repeater which looks like this

<asp:Repeater runat="server" ID="Repeater1">
            <HeaderTemplate>
                <table border="1">
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td>
                        <%# Eval("Username")%>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>

How can I make table layout like this?

enter image description here

Upvotes: 1

Views: 2133

Answers (2)

Sanjay Goswami
Sanjay Goswami

Reputation: 1386

Try Listview

http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx

  <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource" 
        GroupItemCount="2"        
        runat="server">

        <ItemTemplate>

                        <%# Eval("Username")%>

        </ItemTemplate>

      </asp:ListView>

Upvotes: 1

Leon
Leon

Reputation: 3401

A Repeater is a for-loop like structure for rendering markup.

You can accomplish what you're trying to do by using a nested repeater: Outside repeater for <tr>'s and wrap your <td>'s in another repeater.

You can also accomplish this by using asp:DataList control, which is a more elegant solution to what you're trying to do.

Upvotes: 1

Related Questions