One MS social blog on this begins in 2006 and continues to the start of 2013. For a pharmaceutical equivalent to the Tsi Tsi fly’s sleeping sickness, read about it at http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/18544cd3-1083-45fe-b9e7-bb34482b68dd. Then consider at least one workaround to one scenario in which this is happens.
MS originally blamed this on a threading issue. If it is then it’s their threading issue, not Developers’.
Take a DB101 OrderItem System.Data.DataTableRow that is bound to an Infragistics.Win.UltraWinGrid.UltraGridRow. The user selects a product code or SKU. A Developer would be inclined to handle that selection in a fired event. That’s why events exist.
You would be inclined to handle the SKU selection by also setting the item’s price, qty * price, weight, etc. That’s what OrderItem rows do.
But if the SKU selection is handled in an Infragistics.Win.UltraWinGrid.UltraGrid.AfterCellDeactivate event and values of the other fields in the bound DataRow are set at the DataTable level, you may see, "Unable to update the row: DataTable internal index is corrupted: '5'".
Bloggers suspect the root offender is the MS BindingSource.CurrentItemChanged event. Many have suggested the issue can be caused by a DataTable.DefaultView.Sort or failure to surround DataRow field value assignments with DataRow.BeginEdit() and DataRow.EndEdit(). Even after all DataTable.DefaultView.Sorts were eliminated and, to great travail and angst, all DataRow field value assignments were surrounded with BeginEdit() and EndEdit() (why in the world should we tell a data or any object that we are about to change its property values???!!!) – neither effort affected the corrupted DataTable index error in any way.
The error is avoided if other cells in the bound System.Data.DataRow are not updated inside of the AfterCellDeactivate event. That suggests that updates to other DataRow cells be managed in the Infragistics.Win.UltraWinGrid.UltraGrid.BeforeExitEditMode event alone. But that excludes updates to sibling cells when EditMode is never entered.
In certain situations when validation is handled only by a BeforeExitMode event and not additionally [read: redundantly] handled by an accompanying AfterCellDeactivate event (as described below), an UltraGridCell that is bound to an UltraDropDown and a recipient of an invalid SKU will not enter EditMode despite the approval of every “Allow…” property and precursor event like BeforeCellActivate, BeforeEnterEditMode, etc. It won’t even enter EditMode when the cell is clicked. In fact, for some mysterious [read: Infragistics] reason, the cell isn’t even “Active” anymore! The text value of the cell appears to change as the user types (on this supposedly inactive cell), but it is never really in an EditMode and because of that BeforeExitEditMode is not fired, the sibling fields are not updated and any old bogus SKU value appears to be accepted.
To avoid all of that that, an alternate strategy is:
1) Update sibling cells in BeforeExitEditMode for valid SKU values. Set e.Cancel to true for invalid SKUs.
2) Validate SKU values in AfterCellDeactivate. Don’t update sibling cells. If an invalid SKU was entered, simply return a true value for e.Cancel and the UltraGridCell will return to an EditMode on an actually Active cell.
That seems to negate both issues. Unfortunately it incurs a performance hit because the SKU is validated twice which means at least two index seeks on the Product table.
It seems that the core source of the corrupted DataTable index issue is more rooted in the .NET framework than MS is willing to admit. They say the fix is in CLR 4.5. Unfortunately that may be an excessively costly fix because a move to CLR 4.5 will not work on WinXP OS machines.