[英]How to access unbounded Item in DataList
我正在使用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>
谢谢
您的DataList封装了其所有控件。 他们在页面级别不知道。
假设所有控件都将始终存在,您可以尝试:
var myTable = (Table)DataListProducts
.Controls[0]
.FindControl("TableCategories");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.