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);
   }

Comments

Popular posts from this blog

SQL Query :- Create Tables,Primary key,Foreign key,Merge Statment

AngularJS

Check folder and Delete All Files from Existing Folder in C#