我在ItemTemplate中的下一个代码:的FindControl在列表视图的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();
}
我得到空 - 喜欢网页不找到 “喇嘛” 的标签。
我在哪里错了?
这是另一个示例。 http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemdatabound.aspx – 2012-02-08 13:05:31