Dinesh Beniwal
How to create dynamic gridview?
By Dinesh Beniwal in ASP.NET on Apr 20 2012
  • RAHUL SHUKLA
    Jul, 2015 29

    PLease just try this you will get your result using System; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack){ BindGridviewData(); }}protected void BindGridviewData(){System.Web.UI.WebControls.DataGrid DataGrid1 = new System.Web.UI.WebControls.DataGrid();DataTable dt = new DataTable();dt.Columns.Add("UserId", typeof(int));dt.Columns.Add("Name", typeof(string));dt.Columns.Add("Education", typeof(string));dt.Columns.Add("Location", typeof(string));DataRow dr = dt.NewRow();dr["UserId"] = 1;dr["Name"] = "Nisha";dr["Education"] = "High level";dr["Location"] = "Delhi";dt.Rows.Add(dr);dr = dt.NewRow();dr["UserId"] = 2;dr["Name"] = "Rahul";dr["Education"] = "Low level";dr["Location"] = "Mumbai";dt.Rows.Add(dr);DataGrid1.DataSource = dt;DataGrid1.DataBind();form1.Controls.Add(DataGrid1);} }

    • 0
  • Manish Kumar Choudhary
    Nov, 2014 25

    same like as we create dynamic control in asp.net.

    • 0
  • Trilochan Tripathi
    Oct, 2014 14

    create object of gridview row ,cell,header and add at run-time explicitly.

    • 0

Most Popular Job Functions

MOST LIKED QUESTIONS