Praveen S
Praveen S

Reputation: 650

Gridview RowCommand not Fire on Server but works Locally

Gridview RowCommand not fire on server but when i use it on local system it works.But when i publish and post to server RowCommand not fired..shall u give me an solution for this...This is my Grid view Code.

Aspx code:

 <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();
        }
    }

Upvotes: 2

Views: 807

Answers (2)

R.C
R.C

Reputation: 10565

Seems like a viewState Issue. One solution is to set the EnableViewState property of GridView to true.

You have set ViewStateMode="Enabled" , so Not sure what's the final setting your GridView is inheriting.May be the ContentPlaceHolder of the masterpage has viewstate turned off. Try turning it on.

Upvotes: 1

sangram parmar
sangram parmar

Reputation: 8736

content is not allowed between opening and closing tags for element "Button"

So replace your lnkCandidateView button with

<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")%>' />

Upvotes: 1

Related Questions