或可见条件显示两次LinkBut​​ton Inside GridView

时间:2016-10-28 08:29:58

标签: c# asp.net gridview asplinkbutton

我在上面的LinkBut​​tons中调用java脚本,并且所有LinkBut​​ton都在gridview中,基于问题序列号,可以看到LinkBut​​tons。我上面的LinkBut​​ton4工作不正常,OR条件无法正常工作。当我在序列号1或5或10时,然后显示两次按钮。我认为linkbutton4在序列号1或5或10中不是vi-sibling false。

在GridView内使用LinkBut​​tons。

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

1 个答案:

答案 0 :(得分:0)

您的按钮可见性设置应为 AND ,否则它始终返回true。

检查一下:

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