[英]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.