与ASP中继器创建一个HTML表格,水平重复 [英] Create a HTML table with an ASP repeater, repeating horizontally
问题描述
我试图建立使用ASP中继器的HTML表格:</ P>
I'm trying to build a 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>
这是一个基本的表格其中包括在两行和X列即可。
而第一个是不可见的,第二行显示没有任何问题。
任何人都可以帮忙找缺少了什么?
先谢谢了。
This is a basic table which consists in two lines and X columns. The second line appears without any problems while the first one is invisible. Can anyone help to find what's missing? Thanks in advance.
推荐答案
我觉得最核心的问题是,转发
的目的不是要重复水平
I think the core problem is that Repeater
isn't designed to repeat horizontally.
也许你应该尝试使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.repeatdirection.aspx\">DataList这允许指定RepeatingDirection
Maybe you should try using DataList which allows to specify the RepeatingDirection.
更新
如果您不需要重复水平(如你的问题建议......两行和X列),你的转发
应该是这样的。
If you don't need to repeat horizontally (like your question suggests "...two lines 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>
请注意,你不能重复&LT;表&gt;
在&LT;的ItemTemplate&GT;
,并使用单当你需要把你的评估
属性引号内。
Note that you must not repeat the <table>
in your <ItemTemplate>
and to use single quotes when you need to put your Eval
inside an attribute.
这篇关于与ASP中继器创建一个HTML表格,水平重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!