We have an Infragistics UltraGrid in a old WinForms application that is bound to a DataTable. Periodically new records are submitted to this table; either new data or changes to existing data. We can tell if this is an existing row by examining a 'batchID' column. We handle this by first deleting all rows of the DataTable with matching batchID, then adding the new row. Simplified:
for (int i = boundDataTable.Rows.Count - 1; i >= 0; i--){ var r = (MyDataType)boundDataTable.Rows[i]; if (r.batchID == incomingRow.batchID) r.Delete();}boundDataTable.ImportRow(incomingRow as DataRow);
If the incomingRow is a new record this works fine, but if it matches an existing batchID the existing records with the same batchID are removed (which is good) but the new data is not shown (which is bad). boundDataTable.ImportRow is called in both situations, but the new row is only shown in the grid if it was not previously there.
One other thought... is it possible that the new row has already been added to the DataTable before this code fires and is therefore getting deleted immediately?