Dynamic Data Grid View

protected void Button1_Click(object sender, EventArgs e)

{

DataTable dt = new DataTable();

dt.Columns.AddRange(new DataColumn[3]

 { // typeof() is used for dynamic data type allocation

new Column("id",typeof(int)),

new Column("Name",typeof(string)),

new Column("City",typeof(string))

});

dt.Rows.Add(1,"Chitransh","Jabalpur");

dt.Rows.Add(2,"Shashank","Bhopal");

dt.Rows.Add(3,"Ananya","Delhi");

GridView1.Datasource = dt;

GridView1.DataBind();

}


Comments

Popular posts from this blog

Parameter Query

Final Project

Grid View Paging