Gridview RowCommand未在服务器上启动,但在本地工作



Gridview RowCommand没有在服务器上启动,但当我在本地系统上使用它时,它可以工作。但当我发布并发布到服务器时,RowCommand没有被解雇。。你能给我一个解决方案吗。。。这是我的网格视图代码。

Aspx代码:

 <asp:GridView ID="gvCandiList" runat="server" Style="border: 1px;" RowStyle-BorderColor="#ebf3e4"ViewStateMode="Enabled"   RowStyle-BorderStyle="None" GridLines="Both" PageSize="10" AllowPaging="true" AutoGenerateColumns="false" Width="100%" AlternatingRowStyle-BackColor="" CssClass="grdCandList" RowStyle-CssClass="RowStyle" AlternatingRowStyle-CssClass="AltRowStyle" HeaderStyle-CssClass="grdheaderCandList"
DataKeyNames="UserId" OnPageIndexChanging="gvCandiList_PageIndexChanging"  OnRowCommand="gvCandiList_RowCommand"OnRowDataBound="gvCandiList_RowDataBound" AllowSorting="true" OnSorting="gvCandiList_Sorting">
    <EmptyDataTemplate>
      <div class="shadowbox" style="min-height: 75px;">
           <br />
             <center>
                 No Data Found.</center>
          </div>
      </EmptyDataTemplate>
         <Columns>
          <asp:TemplateField HeaderText="Name" ItemStyle-CssClass="grdcolumncenter" HeaderStyle-CssClass="grdcolumnheadermiddle pad_left5 pad_right5 NameHeaderWidth"
                                            SortExpression="CandiName">
      <ItemTemplate>
       <h4 style="font-size: 13px; text-align: left; font-weight: normal !important; color: rgb(67, 73, 75);font-family: Calibri;">
              <asp:LinkButtonID="lnkCandidateView" runat="server" Style="text-decoration: none;
                   color: rgb(67, 73, 75);" onmouseover='mouseover(this);' onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>'>
               <asp:Label ToolTip='<%# Eval("CandiName")%>' ID="lblGrdCandiName" runat="server"Text='<%# Eval("CandiName")%>'></asp:Label></asp:LinkButton></h4>
                <asp:ImageButton ID="ImageButton1" runat="server" Visible="false" ImageUrl="~/Images/edit.png"CommandName="Modi" CommandArgument='<%# Eval("UserId")%>' ToolTip="Edit" />
 <asp:ImageButton ID="ImageButton2" runat="server" ToolTip="View" Visible="false"
                 ImageUrl="~/Images/view.png" CommandName="View" CommandArgument='<%# Eval("UserId")%>' />
                                                <asp:ImageButton ID="ImageButton3" runat="server" ToolTip="Delete" Visible="false" ImageUrl="~/Images/delete.png" CommandName="Del" CommandArgument='<%# Eval("UserId")%>'
 OnClientClick="return confirm('Are you sure ?');" />
                <div style="float: left;">
                   <asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
             <ContentTemplate>
           <asp:ImageButton ID="imgbtnNewCmnt" runat="server" Visible="false" CommandName="NewCmnt" CommandArgument='<%# Eval("CandidateId")%>' ToolTip="New Comment" ImageUrl="~/Images/reminder.png" />
              </ContentTemplate>
              </asp:UpdatePanel>
               </div>
                </ItemTemplate>
              </asp:TemplateField>
     </asp:GridView>

ASPX.CS

protected void gvCandiList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("View"))
        {
            Session["CandiUserId"] = e.CommandArgument.ToString();
            DisplayCandidateDetails();
        }
    }

元素"Button"的开始和结束标签之间不允许有内容

因此,用替换lnkCandidateView按钮

<asp:Button ID="lnkCandidateView" ToolTip='<%# Eval("CandiName")%>' Text='<%# Eval("CandiName")%>'
                                                    runat="server" Style="text-decoration: none; color: rgb(67, 73, 75);" onmouseover='mouseover(this);'
                                                    onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>' />

看起来像是viewState问题。一种解决方案是将GridView的EnableViewState属性设置为true

您已经设置了ViewStateMode="Enabled",所以不确定GridView继承的最终设置是什么。可能是母版页的ContentPlaceHolderviewstate关闭。试着打开它。

最新更新