Datagridview keeps deleting the first row

MartinaL

Newcomer
Joined
Feb 4, 2007
Messages
2
I have this routine that runs when the use clicks delete on a dgv row, but it keeps deleting the first row in the dgv no matter which row i have selected;

Code:
private void dgvDelays_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
        {
            DataRowView selectedRow2 = (DataRowView)bindingDataDelays.Current;

            if (selectedRow2 == null)
            {
                return;
            }

            _delayID = Convert.ToInt32(selectedRow2["DelayID"]);

            DataRow[] currentRows2 = DataComponents.ShiftData.tblUnitDelays
                    .Select("DelayID = " + _delayID);

				foreach (ShiftDataSet.tblUnitDelaysRow row in currentRows2)
				{
                    row.Delete();
				}

                UpdateDelay();
        }
 
Back
Top