title: ADO.NET TableAdapter Updating on CellValueChanged Event for a DataGridView
body: <p>I have a DataGridView which includes a checkbox column for a Boolean variable in the database.</p>
  
  <p>When I click on this checkbox, it fires the events below.</p>
  
  <p>Inside the uiPersonGridView_CellValueChanged event, I call the Data Table Adapter Update method on the Persons Data Table which is the Datasource for the DataGridView.</p>
  
  <p>The Update works fine, the second time but it will still not Update the Current Rows Data?</p>
  
  <p>For example, if I had two rows, if I tick in the first rows check box; Update returns 0 rows updated for int i and I check the database and nothing has been changed. But if I tick on the second rows check box, the Update returns 1 row updated for int i - I check the database and the first record has changed and not the second?</p>
  
  <p>How can I get it work so the update works for the initial change and changes thereafter?</p>
  
  <pre><code>    private void uiPersonGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
      {
          if (uiPersonGridView.IsCurrentCellDirty)
          {
              uiPersonGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
          }
      }
  
      private void uiPersonGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
      {
          if (uiPersonGridView.DataSource == null)
              return;
  
          if (e.RowIndex == -1)
              return;
  
          int i = _personAdapter.Update(_person);
      }
  </code></pre>