C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
3
Reply
How to create dynamic gridview?
Dinesh Beniwal
13y
3.7k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
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);} }
RAHUL SHUKLA
10y
0
same like as we create dynamic control in asp.net.
Manish Kumar Choudhary
11y
0
create object of gridview row ,cell,header and add at run-time explicitly.
Trilochan Tripathi
11y
0
Message