2

我有一个用转发器构建的 HTML 表。有时表格有 5 行,有时有 8 行。

添加标题行很容易。

<asp:PlaceHolder runat="server" ID="additionalHeaderColumns" />

在后面的代码中,我向 contentholder 添加了控件(htmlheadercells):

Dim tableHeaderCell As New TableHeaderCell()
tableHeaderCell.Text = "Test"
additionalHeaderColumns.Controls.Add(tableHeaderCell)

当我尝试在每一行的数据绑定事件中执行相同操作时,我收到一条错误消息,告诉我无法将 asp:PlaceHolder 放在行内。它需要表格单元。

有人有解决方案如何扩展中继器中的列数吗?

4

1 回答 1

0

if i understand your problem as "add columns to the table depending on some data":

<asp:Repeater ID="outerRepeater" runat="server">
    <HeaderTemplate>
        <table>
            <tr>
                <td>fixedHeaderCell</td>
                <td>fixedHeaderCell2</td>
                <asp:Repeater ID="innerColumnRepeater" runat="server" DataSource='<%# someFreakySourceFromYourPageOrOuterRepeater %>'>
                    <ItemTemplate>
                        <td>dynHeaderCell</td>
                    </ItemTemplate>
                </asp:Repeater>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>fixedContentCell</td>
            <td>fixedContentCell2</td>
            <asp:Repeater ID="innerColumnRepeater" runat="server" DataSource='<%# someFreakySourceFromYourPageOrOuterRepeater %>'>
                <ItemTemplate>
                    <td>dynContentCell</td>
                </ItemTemplate>
            </asp:Repeater>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

look further for nested repeater, there is a lot of content here.

于 2010-11-09T13:20:05.860 回答