Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,
I used a datalist control in which i added a gridview template with three columns.
In datalist 2 rows are there that means two gridviews.

Now i want to add rows dynamically in gridview of first row.

How can i do this

Thank you,
Posted

1 solution

C#
DataTable dt = new DataTable();
//this is used to add columns in the database, means columns in your GridView
dt.Columns.Add(new DataColumn("column_name", typeof(string)));
//this is used to initialise datarow
DataRow Dr = dt.NewRow();
//specify column value
Dr["column_name"] = "column_value";
//now you are adding a row in the datatable along with value(s) you specified.
dt.Rows.Add(Dr);
GridView1.DataSource = dt;
GridView1.DataBind();
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 19-Jan-12 4:34am    
Added pre tag
Jagadeesh Bollabathini 19-Jan-12 4:35am    
in which datalist row gridview you are adding this row.
Shailesh g 21-Jan-12 4:23am    
With the code i am adding row in GridViw1. Let me know what and how you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900