这是一个例子。问题是Label2总是Visible = true,无论if-else结果如何。我怎么知道它是否可见?
<asp:GridView runat="server" ID="gdv">
<asp:TemplateField>
<ItemTemplate>
<%if (!IsItem)
{%>
<asp:TextBox runat="server" Text='<%# Eval("Qtde") %>'></asp:TextBox>
<%}
else
{ %>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Qtde") %>'></asp:Label>
<%} %>
</EditItemTemplate>
</asp:TemplateField>
我无法访问IsItem,因为我想检查标签的可见性的类不是页面代码隐藏。这些控件也在gridview中。
检查可见性的类方法不是由页面直接调用的,它是扩展网格视图的服务器控件的私有方法,应该可以处理各种情况。
感谢。
EDIT ------------ 我找到了一个替代的,体面的解决方案。不过,我很想知道是否有可能做到这一点。谢谢你的时间,
答案 0 :(得分:0)
您正在基于名为“IsItem”的变量显示该Label。为什么不能用它来确定Label的可见性?