Sunday 13 July 2014

c# datatable insert column at position 0

dt.Columns.Add("Better", typeof(Boolean)).SetOrdinal(0);
or you can use this // 0 is the position of index where you want to 
add this column, column start at position 0
 DataColumn Col   = datatable.Columns.Add("ColumnA",typeof(Boolean));
    Col.SetOrdinal(0);

if you want to add at position 1 then write this.....
dt.Columns.Add("Better", typeof(Boolean)).SetOrdinal(1);

No comments:

Post a Comment