Add New Columns and Add rows into table from list values in C#
DataTable dtt = new DataTable();
dtt.Columns.Add("Name");
dtt.Columns.Add("ContactID");
dtt.Columns.Add("Date");
foreach (var Item in qu.AsEnumerable())
{
DataRow dr = dtt.NewRow();
dr["Name"] = Item.Name;
dr["ContactID"] = Item.ContactID;
dtt.Rows.Add(dr);
}
dtt.Columns.Add("Name");
dtt.Columns.Add("ContactID");
dtt.Columns.Add("Date");
foreach (var Item in qu.AsEnumerable())
{
DataRow dr = dtt.NewRow();
dr["Name"] = Item.Name;
dr["ContactID"] = Item.ContactID;
dtt.Rows.Add(dr);
}
Comments
Post a Comment