我无法从列表视图访问标签。我一直在阅读所有帖子,但似乎没有任何效果。这是我的代码。
for (int i = 0; i < ListView1.Items.Count; i++)
{
Label someLabel = (Label) ListView1.Items[i].FindControl("nItemsId");
if (someLabel != null)
someLabel.Text = "100";
}
<asp:ListView runat="server" ID="ListView1" DataKeyNames="ProductId" DataSourceID="GameTable" OnItemCommand="On_Select_Item" >
<LayoutTemplate>
<table runat="server" id="gametable" cellspacing="0" cellpadding="1" border="0">
<tr style="height: 20px; font-size: 20px; color: Red">
<th>
<asp:Label runat="server" Text="5" ID="nItemsId" cssClass="cart">
</asp:Label>
</th>
</tr>
......................................
------------------------------
</asp.ListView>