Search My Warehouse

2009-11-10

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:

Feed