Click here to Skip to main content
15,898,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i need to add the new colums in datatable at various positions during runtime
Posted

hi.

try this.
[1]
[2]
[3]


hope it helps.
goodluck. :)




-chaosgray-
 
Share this answer
 
Comments
gowthammanju 6-Jun-11 5:09am    
ya thanks
You can try this...


DataColumn dc1 = new DataColumn();
dc1.DataType = System.Type.GetType("System.Int32");
dc1.ColumnName = "ID";
dc1.AutoIncrement = true;
dc1.AutoIncrementSeed = 1;
dt.Columns.Add(dc1);


DataColumn dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.Caption = "ReportName";
dc.ColumnName = "ReportName";
dt.Columns.Add(dc);

dt.Columns["ReportName"].SetOrdinal(0);
dt.Columns["ID"].SetOrdinal(1);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900