Create a DataTable instance
DataTable table = new DataTable();
Create 7 columns for this DataTable
DataColumn col1 = new DataColumn("ID");
DataColumn col2 = new DataColumn("Name");
Define DataType of the Columns
col1.DataType = System.Type.GetType("System.Int");
col2.DataType = System.Type.GetType("System.String");
Add All These Columns into DataTable table
table.Columns.Add(col1);
table.Columns.Add(col2);
Create a Row in the DataTable table
DataRow row = table.NewRow();
Fill All Columns with Data
row[col1] = 1100;
row[col2] = "Computer Set";
Add the Row into DataTable
table.Rows.Add(row);
Want to bind this DataTable to a GridView?
GridView gvTest=new GridView();
gvTest.DataSource = table;
gvTest.DataBind();