Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add new row in gridview and one column is auto generated value
Posted

1 solution

For Example

int nSlno = 0;
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("BrandId", typeof(int)));

dr = dt.NewRow();
dr["RowNumber"] = nSlno + 1;
dr["BrandId"] = "0";
dt.Rows.Add(dr);
ViewState["CurrentTable"] = dt;
Grid.DataSource = dt;
Grid.DataBind();
 
Share this answer
 
v2
Comments
safihur Rahuman 5-May-14 7:06am    
But BrandId value i am enter in gridview(i.e new row add in button click event)
Laiju k 6-May-14 0:06am    
is your autogenerated value is from database or not

aare you simply adding new row or maintain old values then add a new row

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