Tuesday, 7 August 2012

Add data to the Grid View using Data Table

Add data to the Grid View using Data Table


DataTable dt = new DataTable("DataTable");
DataRow row;

// declared the coloums in the data tables
dt.Columns.Add("Test", typeof(string));

for (int k = 0; k < s; k++)
{
row = dt.NewRow();
row["Software Name"] = software[k];
dt.Rows.Add(row);
}

// adding of the data to the table is completed
GridView1.DataSource = dt;

// the data is binded to the gridview
GridView1.DataBind();

No comments:

Post a Comment