【发布时间】:2012-02-08 12:57:14
【问题描述】:
我在 itemtemplate 中有下一个代码:
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<asp:HiddenField Value='<%# checkCatName(Eval("CatName")) %>' runat="server" />
........
<asp:Label runat="server" id="lblBla" Visible="false"> ... </asp:Label>
</ItemTemplate>
</asp:ListView>
代码隐藏(C#):
public void checkCatName(object CatName)
{
Label bla = (Label)ListView1.FindControl("lblBla");
if (CatName.ToString() == "test1")
bla.Visible = true;
return CatName.ToString();
}
我得到 null - 就像页面找不到“bla”标签。
我哪里错了?
【问题讨论】:
标签: asp.net linq listview itemtemplate