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

CopyTo doesn't work with all rows

1 Answer 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 22 Sep 2008, 08:40 PM
I have a scenario on a form where I need to save all the rows in the form to a collection in memory to save any changes a user has made prior to saving them to a database, but still allow them to swap between different views.

I'm using the SelectionChanged event to handle storing the data, but I have found that calling GridView.Rows.CopyTo()  doesn't work.  I get a GridViewDataRowInfo[] array that is populated with null values.

Sample code is below:
_batchTrays = new Dictionary<int, GridViewDataRowInfo[]>();
int batchNumber = Convert.ToInt32(grid.CurrentRow.Cells["BatchNumber"].Value);
_batchTrays[batchNumber] =  new GridViewDataRowInfo[batchTraysGrid.Rows.Count];
                    batchTraysGrid.Rows.CopyTo(_batchTrays[batchNumber], 0);


this gives me an array populate with null values.

is there a preferred way to accomplish what I am trying to do?

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 24 Sep 2008, 10:37 PM
Hello Christopher,

Thank you for the question.

I am afraid that I cannot understand your case in details. If you are using a RadGridView bound to a DataSet, it has a build-in support for the described scenario. All user changes affect only the DataSet that represents data in the memory. You could easily control when to send the changes to the database through the  DataAdapter.Update method.

If this is not suitable to your application, please, send me more details on it. If you could send me an example project it will be very helpful to investigate your case and provide you with further assistance.

I am looking forward to your reply.

Best wishes,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Christopher
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or