update every second time only

Oct 1 at 3:51 PM
Edited Oct 1 at 5:06 PM
I'm trying to use auto-generated advancedDataGrid.
Problem is that the below shown procedure does not succeed with updating the SQL table every time... It is exactly every second Event raised... If I edit cell for the first (3rd, 5th, etc.) time (CellEndEdit event raised every time, current data picked) - SQL Table cell is not updated. It updates when I edit the DataGrid cell for the second (4th, 6th, etc.) time.
private void advancedDataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
        int rowIdx = advancedDataGridView1.CurrentCell.RowIndex;
        DataRowView drv = (DataRowView)advancedDataGridView1.Rows[rowIdx].DataBoundItem;
        DataRow dr = drv.Row;
        this.levTableAdapter.Update(dr); //strange, but Update is done every second time....
    }
How to debug it?

EDIT: Looked into behaviour again and I have to update:

1st enter "A" - noChangeSQL, Event picks "A", "A" in the datagrid cell.
2nd enter "B" - "A" in SQL, Event picks "A", "A" in cell.
3rd enter "C" - "A" in SQL, Event picks "C", "C" in cell.
4rd enter "D" - "C" in SQL, Event picks "C", "C" in cell.
5th enter "E" - "C" in SQL, Event picks "E", "E" in cell.
Oct 1 at 5:44 PM
I just got the answer somewhere else, but I post it here, to have a complete solution: https://stackoverflow.com/questions/46513792/adgv-c-sharp-datagridview-update-query-bug
        private void advancedDataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int rowIdx = advancedDataGridView1.CurrentCell.RowIndex;
            DataRowView drv = (DataRowView)advancedDataGridView1.Rows[rowIdx].DataBoundItem;
            DataRow dr = drv.Row;
            BeginInvoke((Action)(() => SaveRowChanges(dr)));
         }

        private void SaveRowChanges(DataRow dr)
        {
            DataRow[] rows = { dr };
            this.levTableAdapter.Update(rows);
         }