Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 597.9k

how to add column in datatable in c# with default value c#?

Jun 29 2016 5:17 AM
Sir,
 
adp.Fill(ds);
After fill the database items, I want to add extra coloum with new arraylist values
DataRow drr = ds.Tables[0].NewRow();
ds.Tables[0].Columns.Add("Column1", typeof(string));
ArrayList listArr = new ArrayList();
listArr.Add(SchemeColorValues.Accent1);
listArr.Add(SchemeColorValues.Accent2);
listArr.Add(SchemeColorValues.Accent3);
listArr.Add(SchemeColorValues.Accent4);
foreach (var data in listArr)
{
//How can fill listArr each value here to datatable coloum name 'Column1'?
}
dt = ds.Tables[0];
Kindly replay me.

Answers (6)