我正在使用DataList
。 ItemTemplate
有限。我添加一个HeaderTemplate
,并将其放在一个表中,这将需要包含我在每个FormLoad中添加的动态标签。我不希望标题有界。
我正在尝试访问此表,但它向我显示此表不存在或无法访问。
if (this.TableCategories.Rows.Count == 0 ||
this.TableCategories.Rows[this.TableCategories.Rows.Count - 1].Cells.Count == 5)
{
TableRow newRow = new TableRow();
this.TableCategories.Rows.Add(newRow);
}
<asp:DataList ID="DataListProducts" runat="server" RepeatDirection="Horizontal"
OnItemCommand="DataListProducts_ItemCommand" Height="200px" Width="100%"
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
CellPadding="0" GridLines="Vertical" RepeatColumns="6">
<HeaderTemplate>
<asp:Table ID="TableCategories" runat="server" BorderColor="Black"
CssClass="floatRight" BorderStyle="Inset" BorderWidth="2px" GridLines="Both">
</asp:Table>
</HeaderTemplate>
由于
答案 0 :(得分:0)
您的DataList封装了其所有控件。他们在页面级别不知道。
假设所有控件都在那里,您可以尝试:
var myTable = (Table)DataListProducts
.Controls[0]
.FindControl("TableCategories");