say I display a datatable on a datagridview, then the user sorts it, and selects a row… I want to do something with the original datatable to the same row… but the row indexes in the datagridview and datatable are now out of sync. How should I be doing this?
Share
A couple things come to mind.
You can requery the DataTable’s data source.
You can programmatically add a Column to your DataTable that acts as an index of the DT’s original row order. When you want to restore the sort order, sort on this column. I’ve done this. You can set the new Column’s AutoIncrement property to true and the column’s values will be filled in for you.
HTH