re-order columns in a DataTable
Hi all,
I was wondering if there is an easy way to re-order the DataColumns in a DataTable.
Thanks,
Mark.
Hi all,
I was wondering if there is an easy way to re-order the DataColumns in a DataTable.
Thanks,
Mark.
spanky4_3 wrote:
Hi all,
I was wondering if there is an easy way to re-order the DataColumns in a DataTable.
Thanks,
Mark.
Hi,
Use the setOrdinal method of the datacolumn. It would ask for the new position in the collection...
datatable.Columns["Col1"].SetOrdinal(1);
cheers,
Paul June A. Domag
Thanks for that Paul it worked perfectly.
Also sorry ahmedilyas that my question was a little vague. I only wanted to shift the index order of the columns in a DataTable. For example, if I had a DataTable with columns col1, col2 & col3 (in that order) I wanted to know how to re-order them to col2, col3 & col1.
Regards,
Mark.