开发者

ASP.NET How to know if control in page if-else is visible?

Here is an example. The problem is that the Label2 has always Visible=true, regardless of the if-else result. How can i know if its visible or not?

<asp:GridView runat="server" ID="gdv">
<asp:TemplateField>
<ItemTempl开发者_如何学运维ate>

  <%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>

I cannot access IsItem, since the class where i want to check the label for visibility is not the page code-behind. Also these controls are in a gridview.

The class method that checks for visibility is not called directly by the page, its a private method of a server control that extends a grid view and is supposed to work with a varierty of cases.

Thanks.

EDIT------------ I have found an alternative, decent solution. Still, i'm curious to know if it's possible to do the aforementioned. Thanks you for your time,


You are displaying that Label based on a variable called "IsItem." Why can't you use that to determine the Label's visibility?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜