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

WPF Grid Row Duplication

1 Answer 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez asked on 16 Dec 2009, 04:05 AM
Hello,
     I need to duplicate the selected row on the grid 1-N times. The duplicates will appear below the selected row. The grid is bound to a datatable in a dataset. The only way I've figured to do this is:

for (int i = 0; i <number of duplicates>; i++)
{
  Datarow dr = datatablename.NewRow();
  dr.ItemArray = datatablename.Rows[<position of row in grid to duplicate>].ItemArray;
  datatablename.Rows.InsertAt(dr, <position of row in grid to duplicate> + 1);
  dr = null;
}

Is this the correct way to duplicate rows?

Thanks

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Dec 2009, 07:31 AM
Hi Jorge,

It looks fine to me! Don't hesitate to contact us if you have other questions.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Jorge Gonzalez
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or