11/13/2012
How to create a Data Table Programmatically in C#
Creating a Data Table Programmatically using C#
protected void BindInfo()
{
column = new DataColumn();
column.ColumnName = "OrderID";
dt.Columns.Add(column);
column = new DataColumn();
column.ColumnName = "OrderName";
dt.Columns.Add(column);
column = new DataColumn();
column.ColumnName = "Address1";
dt.Columns.Add(column);
column = new DataColumn();
column.ColumnName = "Address2";
dt.Columns.Add(column);
column = new DataColumn();
column.ColumnName = "Mobile Number";
dt.Columns.Add(column);
row = dt.NewRow();
row["OrderID"] = "L-A4300";
row["OrderName"] = "Navya -1";
row["Address1"] = "TestAddress1";
row["Address2"] = "TestAddress2";
row["Mobile Number"] = "9999484910";
dt.Rows.Add(row);
row = dt.NewRow();
row["OrderID"] = "L-A4400";
row["OrderName"] = "Navya -2";
row["Address1"] = "TestAddress11";
row["Address2"] = "TestAddress22";
row["Mobile Number"] = "8888484910";
dt.Rows.Add(row);
}