Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a grid view, with 'select' button in each row,i renamed this 'select' button as 'copy row'.my requirement is, when i click on this copy row button, a new row has to add below the selected row. and i succeed in this.
for this, i wrote code in "gridview_selectedIndexChanging" event as:
C#
int i = e.NewSelectedIndex;
GridViewRow gr = GridView1.Rows[i];
GridViewRow row = new GridViewRow(i, i, DataControlRowType.DataRow, DataControlRowState.Insert);
GridView1.Controls[0].Controls.AddAt(i + 2, row);

I succeed in this scenario.
But when i click on another 'copy row' button, first copied row has not persisted;and i have failed in this case.

Hope i will get an optimum solution.

Thanks in advance,
Posted
v3
Comments
Richard C Bishop 1-Apr-13 9:59am    
You have to do an Insert statement if you want the database to have a new row, keep in mind the primary keys will have to be different.

1 solution

Use MVC and JQuery for such a web application.
Then you can do any thing you want.
Asp.net Web Form Model is for small and simple application.
Please dont waste your life on these server controles.
 
Share this answer
 
Comments
siddu1221 12-Apr-13 0:56am    
sorry,I have already developed this application using asp.net web forms and I use grid view also. This requirement came later.I need to complete in this scenario only.help me in this scenario.Thanks

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