title: ASP.NET c# Gridview OnRowUpdating not working
body: <p>I'm working in Visual Studio 2015.
  When the Gridview loads, I can click on "Edit".
  When I click Cancel I'm just getting back to the Gridview. 
  So that good, but if I click "Update" he is doing the same thing as what is happening at "Cancel". No errors.</p>
  
  <p>Here is the method for the OnRowUpdating :</p>
  
  <pre><code>protected void UpdateHandleiding(object sender, GridViewUpdateEventArgs e)
          {         
              SqlConnection Sqlconnection1 = new SqlConnection();
              Sqlconnection1.ConnectionString = (System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
              //string ID = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblID")).Text;
              //string Naam = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNaam")).Text;
              //string URL = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtURL")).Text;
  
              GridViewRow row = GridView1.Rows[e.RowIndex];
              int ID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
              string Naam = (row.Cells[1].Controls[0] as TextBox).Text;
              string URL = (row.Cells[2].Controls[0] as TextBox).Text;
  
              using (SqlConnection con = new SqlConnection(strConnString))
              {
                  using (SqlCommand cmd = new SqlCommand("UPDATE Handleidingen SET Naam=@Naam, URL=@URL WHERE ID=@ID"))
                  {
                      cmd.Parameters.AddWithValue("@ID", ID);
                      cmd.Parameters.AddWithValue("@Naam", Naam);
                      cmd.Parameters.AddWithValue("@URL", URL);
                      cmd.Connection = con;
                      con.Open();
                      cmd.ExecuteNonQuery();
                      con.Close();
                  }
  
              }
  
              GridView1.EditIndex = -1;
              GridView1.DataBind();
          }
  </code></pre>
  
  <p>Here is my OnRowEditing &amp; OnRowCancelingEdit which do work :</p>
  
  <pre><code>    protected void EditHandleiding(object sender, GridViewEditEventArgs e)
      {
          GridView1.EditIndex = e.NewEditIndex;
          ShowHandleidingen();
      }
      protected void CancelEdit(object sender, GridViewCancelEditEventArgs e)
      {
          GridView1.EditIndex = -1;
          ShowHandleidingen();
      }
  </code></pre>
  
  <p>Here is my Gridview :</p>
  
  <pre><code>                    &lt;asp:GridView ID="GridView1" runat="server" CssClass="grid-center" AutoGenerateColumns="False"
                          DataKeyNames="ID" EnableModelValidation="True" OnRowDeleting="GridView1_RowDeleting"
                          OnRowEditing="EditHandleiding" OnRowUpdating="UpdateHandleiding" OnRowCancelingEdit="CancelEdit"&gt;
                          &lt;Columns&gt;
                              &lt;asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /&gt;
                              &lt;asp:BoundField DataField="Naam" HeaderText="Naam"/&gt;
                              &lt;asp:BoundField DataField="URL" HeaderText="URL"/&gt;
                              &lt;asp:CommandField ShowEditButton="True" /&gt;
                              &lt;asp:CommandField ShowDeleteButton="true" /&gt;
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
  </code></pre>