Create an HTML table with ASP relay repeating horizontally

I am trying to create an HTML table using an ASP repeater:

<asp:Repeater ID="RepeaterVersionsForPie" runat="server"> <ItemTemplate> <table id="VersionsTable" > <tr> <th> <%#Eval("nameVersion")%> </th> </tr> </ItemTemplate> <ItemTemplate> <tbody> <tr> <td tag="<%#Eval("idVersion")%>"> <%#Eval("NumberOfCompaniesUsingThisVersion")%> </td> </tr> </tbody> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> 

This is a base table consisting of two rows and columns of X. The second line appears without problems, while the first is invisible. Can anyone help find the missing ones? Thanks in advance.

+6
source share
1 answer

I think the main problem is that Repeater not intended to be horizontal repetition.

Maybe you should try a DataList that lets you specify a RepeatingDirection.

Update

If you do not need to repeat horizontally (for example, your question assumes "... two rows and X columns"), your Repeater should look like this:

 <asp:Repeater ID="RepeaterVersionsForPie" runat="server"> <HeaderTemplate> <table id="VersionsTable"> </HeaderTemplate> <ItemTemplate> <tr> <th><%# Eval("nameVersion") %></th> <!-- Important: Put attributes in single quotes so they don't get mixed up with your #Eval("xxx") double quotes! --> <td tag='<%#Eval("idVersion")%>'> <%# Eval("DocumentName") %> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> 

Note that you should not repeat <table> in <ItemTemplate> and use single quotes when you need to put your Eval inside an attribute.

+9
source

Source: https://habr.com/ru/post/908893/


All Articles