How to use asp:placeholder inside a repeater
I have a HTML table that is built with a repeater. Sometimes the table has 5 rows, sometimes it has 8 rows.
It was easy to add the header rows.
<asp:PlaceHolder runat="server" ID="additionalHeaderColumns" />
In code behind I added controls 开发者_Python百科(htmlheadercells) to the contentholder:
Dim tableHeaderCell As New TableHeaderCell()
tableHeaderCell.Text = "Test"
additionalHeaderColumns.Controls.Add(tableHeaderCell)
When I try to do the same in the databound event for each row I get an errormessage that tells that its not possible to put asp:PlaceHolder inside the row. it expects tablecells.
Anybody have a solution how to expand number of columns in a repeater?
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.
精彩评论