Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear frinds,

I am try to add new row to gridview but not success, can any body suggest me how can add new row and assign variable to cell
Posted
Comments
Kornfeld Eliyahu Peter 18-Dec-14 2:40am    
Please show us your code...

User below code,

DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Col1", typeof(string)));
dt.Columns.Add(new DataColumn("Col2", typeof(string)));
dt.Columns.Add(new DataColumn("Col3", typeof(string)));
dt.Columns.Add(new DataColumn("Col4", typeof(string)));
dt.Columns.Add(new DataColumn("Col5", typeof(string)));
dr = dt.NewRow();
dr["RowNumber"] = 1;
dr["Col1"] = string.Empty;
dr["Col2"] = string.Empty;
dr["Col3"] = string.Empty;
dr["Col4"] = string.Empty;
dr["Col5"] = string.Empty;
dt.Rows.Add(dr);

I think its work.
 
Share this answer
 
HI, hope this link will help you:

How to insert blank row in the grid view in asp.net[^]
 
Share this answer
 
set edit Index of Gridview to -1 on binding and row would be added directly to it
 
Share this answer
 
i am all ready have grid view and just i want add new row empty, Just in first column there is data.
 
Share this answer
 

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