Powered By Blogger

Monday, November 9, 2009

Dynamic Datatable in C#

Create DataTable Dynamically using C#

DataTable DT = new DataTable();


//Create Column

DT.Columns.Add("Column 1");
DT.Columns.Add("Column 2");
DT.Columns.Add("Column 3");

//End Column

//Create and Add New Row

DataRow DTRow= DT.NewRow();

//Inserting values to each cell in a row

DTRow[0] = "First cell";
DTRow[1] = "Second cell";
DTRow[2] = "Third cell";

DT.Rows.Add(DTRow);

No comments:

Post a Comment