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

RadGridView - save changes to a rows data back to database

1 Answer 1280 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 12 Apr 2011, 10:45 AM
Hi there

I'm trying to achieve row-level validation and saving. The validation is working OK and and I can reject invalid user-input at the row level.

However I'm a bit lost as to how which event to use to catch the fact a row has changed so I can then call dataset.savechanges().

I've tried -
RowsChanged event but it fires when the grid is first populated with data
RowValidated event but it fires AFTER I leave the row that was updated
RowValidating event which is nearly there but it isn't until it's finished that I can detect changes in my dataset using datatable.getchanges()

The basic point is that i'd like remove the need for a Save button that will save ALL changes to the data in the grid. The reason for this is that the database has lots of users and I want to maintain concurrency. If I can get the database record to change when a ROW is updated then there is less chance of concurrency issues.

Thanks in advance



1 Answer, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 12 Apr 2011, 11:11 AM
Hello Ian,

Personally, I would provide a single button to save back all the changes at the end. But you can use the RowsChanged event and inspect the Action to ensure you are only picking up changed items. This will fire once the value has actually changed. This is when the editor closes, e.g. when you move away from the cell or press enter.

void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.ItemChanged)
    {
        MessageBox.Show("Save");
    }
}

Hope that helps but let me know if you need more information
Richard
Tags
GridView
Asked by
Ian
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or