Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Grid events/save changes
posted

Hi there,

We are having some problems with saving changes that are made in the grid when the events are fired from a control that is also contained in the grid.

For example, we have a cell in each row that contains a button.  When this button is clicked it should save all changes that have been made and then open up a different screen.  When we run through the code, it knows that changes have been made, but they are all lost and nothing gets saved.  We reload the grid and all the original values come back.

Another example of when this happens is, we are using a context menu control for when the user right clicks on a cell we give them an option to fill in the rest of the row with the value from the cell they clicked on.  When we try and save this however, once again the changes are not recognized and the old values return.

It seems like this only happens when events are fired from the grid itself.  If I copy and paste values from one cell to all the others then the save works fine, but if I try and automate the process it does not.

The grid is bound to a datasource and this is what we are using to compare against and check for changes.  Pleas esee the code snippet below...

 

dsExpenses

 

 

ds = (dsExpenses

)grdExpenseData.DataSource;

 

 

var dsChanges = (dsExpenses

)ds.GetChanges();

 

  • 469350
    Suggested Answer
    Offline posted

    The grid commits the changes to it's underlying DataSource based on the UpdateMode property. By default, this happens OnCellChangeOrLostFocus.

    So if you want to save the change without leaving the cell or changing focus on the grid, you need to call UpdateData on the grid in code.