Ways of adding Rows into DataTable

Rajesh_Kumar
Posted by Rajesh_Kumar under ASP.NET category on | Points: 40 | Views : 495
1st Way:

DataTable dt1 = new DataTable();
dt1.Columns.Add("project_id");
dt1.Columns.Add("project_name");

dt1.Rows.Add("1", "Hospital Management");
dt1.Rows.Add("2", "Job Site");
dt1.Rows.Add("3", "Resume Manager");


2nd Way:
DataRow dr = dt1.NewRow();
dr["project_id"] = "4";
dr["project_name"] = "College Management";

dt1.Rows.Add(dt1);

Comments or Responses

Login to post response