c# datatable insert column at position 0

Grant picture Grant · Aug 27, 2009 · Viewed 100.8k times · Source

does anyone know the best way to insert a column in a datatable at position 0?

Answer

Wael Dalloul picture Wael Dalloul · Aug 27, 2009

You can use the following code to add column to Datatable at postion 0:

    DataColumn Col   = datatable.Columns.Add("Column Name", System.Type.GetType("System.Boolean"));
    Col.SetOrdinal(0);// to put the column in position 0;