title: The GridView ' ' fired event RowUpdating which wasn't handled. C# code behind asp.net
body: <p>There are similar questions on Stackoverflow and other websites, but I seem to miss something.</p>
  
  <p>I have a GridView bound to a DataTable which comes from a database. My goal is to update the one row  at the time with a button which is in the same row which calls the following Method.</p>
  
  <pre><code>        protected void TestsToBeDone_RowUpdating(object sender, GridViewEditEventArgs e)
      {
          SqlConnection myConnection = getConnection();
          myConnection.Open();
  
          int index = Convert.ToInt32(e.NewEditIndex);
  
          GridViewRow selectedRow = TestsToBeDone.Rows[index];
          TableCell LABAVIDc = selectedRow.Cells[1];
          int LABAVID = Convert.ToInt32(LABAVIDc.Text);
  
          TableCell assistentc = selectedRow.Cells[5];
  
          string query = "UPDATE Labaanvraag " +
                         "SET Status='4' "+
                                   "WHERE LABAVID ='"+LABAVID+"'";
          }
  
          SqlCommand commandZ = new SqlCommand(query, myConnection);
          commandZ.ExecuteNonQuery();            
  
          myConnection.Close();
  
          SetPatientTestGrid(Session["PATID"], e);
      }
  </code></pre>
  
  <p>It is being called from here:</p>
  
  <pre><code>    &lt;asp:GridView ID="TestsToBeDone" runat="server" EnableModelValidation="True" OnRowEditing="TestsToBeDone_RowUpdating"&gt;
      &lt;Columns&gt;
          &lt;asp:ButtonField ButtonType="Button" CommandName="Update" 
              HeaderText="Afgenomen" ShowHeader="True" Text="Afgenomen" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>At my first try I had a OnRowCommand with the GridViewCommandEventArgs at the code behind.</p>
  
  <p>But it still throws the same exception, although I've read on a couple of sites that changing it to OnRowEditing and GridViewEditEventArgs would solve the problem.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Tim A</p>