mazhar 124 mazhar 124 - 1 month ago 6
ASP.NET (C#) Question

OR Visible condition showing twice LinkButton Inside GridView

I am calling java script in above LinkButtons and all LinkButtons are inside into gridview base on question serial number doing visibility of LinkButtons. My above LinkButton4 is not working properly and

OR
condition is not working properly. When I am on serial number 1 or 5 or 10 then showing twice buttons. I think linkbutton4 is not vi-sibling false in serial number 1 or 5 or 10.

Below LinkButtons using inside GridView.

<asp:LinkButton CssClass="btn savennext btn-large skip" ID="LinkButton_SAVE_NEXT"
OnClick="LinkButton_SAVE_NEXT_Click" runat="server" Visible='<%# Eval("QuestionSNo").ToString() == "1"%>' OnClientClick="return takepic();">SAVE & NEXT</asp:LinkButton>

<asp:LinkButton CssClass="btn savennext btn-large skip" ID="LinkButton1"
OnClick="LinkButton_SAVE_NEXT_Click" runat="server" Visible='<%# Eval("QuestionSNo").ToString() == "5"%>' OnClientClick="return takepic1();">SAVE & NEXT</asp:LinkButton>

<asp:LinkButton CssClass="btn savennext btn-large skip" ID="LinkButton3"
OnClick="LinkButton_SAVE_NEXT_Click" runat="server" Visible='<%# Eval("QuestionSNo").ToString() == "10"%>' OnClientClick="return takepic2();">SAVE & NEXT</asp:LinkButton>

<asp:LinkButton CssClass="btn savennext btn-large skip" ID="LinkButton4"
OnClick="LinkButton_SAVE_NEXT_Click" runat="server" Visible='<%# Eval("QuestionSNo").ToString() != "1" || Eval("QuestionSNo").ToString() != "5" || Eval("QuestionSNo").ToString() != "10"%>'>SAVE & NEXT</asp:LinkButton>

Answer

Your button visibility desing should be AND otherwise it always returns true.

Check this:

   <asp:LinkButton CssClass="btn savennext btn-large skip" ID="LinkButton4"
   OnClick="LinkButton_SAVE_NEXT_Click" runat="server" Visible='<%# Eval("QuestionSNo").ToString() != "1" && Eval("QuestionSNo").ToString() != "5" && Eval("QuestionSNo").ToString() != "10"%>'>SAVE & NEXT</asp:LinkButton>
Comments