I’m using a DataTable with the contents
column1 column2 column3 column4 column5 column6 column7 column8 column9 column10
row1 a b c d e f g h i j
I want the table to be reorderd as
column4 column2 column1 column7 column6 column9 column10 column5 column8 column3
row1 d b a g f i j e h c
I tried using the DataTable.Column[i].SetOrdinal() method but it swaps only the first column properly.
Since you haven’t shown the full code it’s difficult to say what’s actually wrong. But this should work:
Instead of a
params String[]you could also use aList<DataColumn>or whatelse you prefer.Tested with your sample data:
Works already with .NET 2.