title: Unable to cast object of type 'System.Web.UI.WebControls.Button' to type 'System.Web.UI.WebControls.LinkButton'
body: <p>i try to approve documents 
  but when i click on approve button 
  it show me error</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Web.UI.WebControls.Button' to type 'System.Web.UI.WebControls.LinkButton'.</p>
  </blockquote>
  
  <p>gridview</p>
  
  <pre><code>&lt;asp:GridView ID="GrdFileApprove" runat="server" AutoGenerateColumns="False" 
                  onrowcommand="GrdFileApprove_RowCommand"&gt;
                 &lt;Columns&gt;
                     &lt;asp:TemplateField HeaderText="S no"&gt;
                         &lt;ItemTemplate&gt;
                             &lt;%# Container.DataItemIndex+1 %&gt;
                             &lt;asp:HiddenField runat="server" ID="HdnFileID" Value='&lt;%# 
                        Eval("DocID") %&gt;' /&gt;
                         &lt;/ItemTemplate&gt;
                     &lt;/asp:TemplateField&gt;
                     &lt;asp:BoundField DataField="DocID" HeaderText="DocumentID"  /&gt;
                     &lt;asp:BoundField DataField="DocName" HeaderText="DocName"  /&gt;
                     &lt;asp:BoundField DataField="Uploadfile" HeaderText="File Name" /&gt;
                     &lt;asp:BoundField DataField="DocType" HeaderText="Document" /&gt;
                     &lt;asp:BoundField DataField="DepType" HeaderText="Department" /&gt;
                     &lt;asp:TemplateField HeaderText="S no"&gt;
                         &lt;ItemTemplate&gt;
  
  
                             &lt;asp:Button runat="server" Id="BtnApprove"
                             CommandName="_Approve" 
  
                                  CommandArgument='&lt;%# Eval("DocID") %&gt;' Text="Aprrove"
                               /&gt;
  
                             &lt;asp:Button runat="server" Id="Button1" 
                           CommandName="_Reject" 
                                  CommandArgument='&lt;%# Eval("DocID") %&gt;' Text="Reject" /&gt;
                         &lt;/ItemTemplate&gt;
                     &lt;/asp:TemplateField&gt;
                     &lt;asp:ButtonField Text="Button" /&gt;
                 &lt;/Columns&gt;
             &lt;/asp:GridView&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>code </p>
  
  <pre><code>if (e.CommandName == "_Approve")
          {
              //using (SqlConnection con = DataAccess.GetConnected())
              using (SqlConnection con = new 
          SqlConnection(ConfigurationManager.ConnectionStrings
  
           ["mydms"].ConnectionString))
              {
                  try
                  {
                      int rowindex = Convert.ToInt32(e.CommandArgument);
                      GridViewRow row = (GridViewRow)
            ((Control)e.CommandSource).NamingContainer;
                      LinkButton Prove_Button = 
               (LinkButton)row.FindControl("BtnApprove");
                      SqlCommand cmd = new SqlCommand("spinsertapprove", con);
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.Add(new SqlParameter("@UserID", UserID));
                      cmd.Parameters.Add(new SqlParameter("@DocID", DocID));
                      cmd.Parameters.Add(new SqlParameter("@ApproveType", "Approve"));
                      int result = cmd.ExecuteNonQuery();
                      if (result != 0)
                      {
                          GrdFileApprove.DataBind();
                      }
                  }
  
                  catch
                  {
                      apfi.Text = "Not Approve";
  
  
  
                  }
                  finally
                  {
                      con.Close();
                  }
              }
          }
  
  
          else if (e.CommandName == "_Reject")
          {
              using (SqlConnection con = new 
               SqlConnection(ConfigurationManager.ConnectionStrings
  
              ["mydms"].ConnectionString))
              {
                  try
                  {
                      int rowindex = Convert.ToInt32(e.CommandArgument);
                      GridViewRow row = (GridViewRow)
                ((Control)e.CommandSource).NamingContainer;
                      LinkButton Prove_Button = (LinkButton)row.FindControl("Button1");
                      SqlCommand cmd = new SqlCommand("sprejectapprove", con);
  
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.Add(new SqlParameter("@UserID",UserID));
                      cmd.Parameters.Add(new SqlParameter("@DocID", DocID));
                      cmd.Parameters.Add(new SqlParameter("@ApproveType", "Reject"));
                      int result = cmd.ExecuteNonQuery();
                      if (result != 0)
                      {
                          GrdFileApprove.DataBind();
                      }
                  }
  
                  catch 
                  {
                      apfi.Text = "Rejct";
                  }
                  finally
                  {
                      con.Close();
                  }
              }
          }
  </code></pre>
  
  <p>it shows me error in catch when click on approve button</p>