D
dotnetstevo
I am trying to manipulate the data in a DataTable
I want to move a row from one position to another
my code works so far. It goes like:
//index is the index of the row I want to move
DataRow drRowToMove = MyDataTable.Rows[index];
MyDataTable.Rows.RemoveAt(index);
MyDataTable.Rows.InsertAt(drRowToMove, index - 1);
MyDataTable.AcceptChanges();
It works, I get a reordered DataTable
but the problem is that the new inserted row (that should have been
moved) is blank, ie it contains no data
I have debugged the code and it appears that "drRowToMove" contains no
data after it has been "removedAt" on the line before
so....basically (to cut a long story short
I want to copy the data in the row BEFORE calling the RemoveAt method
so that I can insert a fresh row with the previous data
Any ideas?
I want to move a row from one position to another
my code works so far. It goes like:
//index is the index of the row I want to move
DataRow drRowToMove = MyDataTable.Rows[index];
MyDataTable.Rows.RemoveAt(index);
MyDataTable.Rows.InsertAt(drRowToMove, index - 1);
MyDataTable.AcceptChanges();
It works, I get a reordered DataTable
but the problem is that the new inserted row (that should have been
moved) is blank, ie it contains no data
I have debugged the code and it appears that "drRowToMove" contains no
data after it has been "removedAt" on the line before
so....basically (to cut a long story short
I want to copy the data in the row BEFORE calling the RemoveAt method
so that I can insert a fresh row with the previous data
Any ideas?