This is a migrated thread and some comments may be shown as answers.

copy selected row to a new row in the same gridview

3 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
francis
Top achievements
Rank 1
francis asked on 05 Mar 2011, 02:54 AM
Hello,

I'd like to be able to select a row in a gridview, then click a button that would insert a new row in the same gridview with the same values as the selected row.

Any help to get me started would be appreciated.

Thanks
Francis

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 05 Mar 2011, 11:07 AM
Hello Francis,

This should be fairly straightforward. It will differ though depending on whether you are using the grid in bound or unbound mode.
In bound mode, you would take the
radGridView1.CurrentRow.DataBoundItem
and then programatically copy each of it's values to a new custom object, data row or whatever your grid is bound to, and add the new one to your datasource.

In unbound mode, much the same, but you would need to loop over columns for the current row, and programatically insert a new row with the same values as the current row.

Hope this helps but let me know if you have any questions
Richard
0
francis
Top achievements
Rank 1
answered on 05 Mar 2011, 04:07 PM
Thanks Richard...that's what i ended up doing but wanted to see if there was another way as well.

Thanks for the quick reply
Francis
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 05 Mar 2011, 04:30 PM
You're welcome. Please remember to mark as answer and if you have any further questions on this, just let me know
Regards,
Richard
Tags
GridView
Asked by
francis
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
francis
Top achievements
Rank 1
Share this question
or