本文介绍了使用 ASP 中继器创建 HTML 表格,水平重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ASP 转发器构建 HTML 表格:

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.

推荐答案

我认为核心问题是 Repeater 不是为了水平重复而设计的.

I think the core problem is that Repeater isn't designed to repeat horizontally.

也许您应该尝试使用 DataList允许指定重复方向.

Maybe you should try using DataList which allows to specify the RepeatingDirection.

更新

如果您不需要水平重复(就像您的问题建议...两行和 X 列"),您的 Repeater 应该如下所示

If you don't need to repeat horizontally (like your question suggests "...two lines and X columns") your Repeatershould 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>

请注意,您不得在 中重复

并在需要放置 Eval 在属性中.

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 表格,水平重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 06:14