title: Cannot detect row in gridview while update data
body: <p>I want to update the AResult with click approve or reject button. </p>
  
  <p>In my aspx page, here my code,</p>
  
  <pre><code>&lt;asp:ButtonField ButtonType="Button" CommandName="Approve" Text="Approve" runat="server" /&gt;
  &lt;asp:ButtonField ButtonType="Button" CommandName="Reject" Text="Reject" runat="server" /&gt;
  </code></pre>
  
  <p>My aspx.vb code,</p>
  
  <pre><code>Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView1.RowCommand
  
      Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("dbconnection").ConnectionString)
  
  
      con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
      con.Open()
  
  
  
  
      If e.CommandName.CompareTo("Approve") = 0 OrElse _
         e.CommandName.CompareTo("Reject") = 0 Then
          ' The Approve or Reject Button has been clicked
          ' Determine the ID of the appointment whose result was adjusted
  
          Dim AID As Integer = Convert.ToInt32(_GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)
  
  
          Dim cmd As New SqlCommand
  
          cmd.Connection = con
          If e.CommandName.CompareTo("Approve") = 0 Then
              cmd = New SqlCommand("UPDATE [Appointment] SET AResulT  = N'Approve'", con)
  
  
          ElseIf e.CommandName.CompareTo("Reject") = 0 Then
              cmd = New SqlCommand("UPDATE [Appointment] SET AResult = N'Reject'", con)
  
  
          End If
  
          cmd.ExecuteNonQuery()
  
          Response.Redirect("Waiting List")
  
          con.Close()
  
  
      End If
  End Sub
  </code></pre>
  
  <p>When i click on approve button, it will update my whole appointment's result with approve. Can someone teach me how to detect the row when i click the button? </p>