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

[Solved] What is proper way to cancel update after exception?

1 Answer 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 28 Dec 2009, 03:28 PM
Hello,
I'm using RadGrid 2009.3 with LLBLGenProDataSource2 data source control and the following settings:

grid.MasterTableView.EditMode =

GridEditMode.EditForms;

 

grid.MasterTableView.EditFormSettings.EditFormType =

GridEditFormType.AutoGenerated;

Whenever user attempts to Update a record that results in the exception, I handle the exception through ItemUpdated event:

 

 

 

    private static void grid_ItemUpdated(object source, GridUpdatedEventArgs e)  
    {  
        if (e.Exception != null)  
        {  
            HandleInsertUpdateException((source as RadGrid), e, false);  
 
            e.ExceptionHandled = true;  
            e.KeepInEditMode = true;              
        }  
    } 


where HandleInsertUpdateException is my function for printing the error message.

The problem I'm faced with is this: whenever the user hits the Cancel link, the updated (incorrect) value still gets displayed in the grid.

What is the proper way to refresh the grid to have it display the original value whenever Update fails?

 

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 29 Dec 2009, 02:13 PM
Hi Albert,

If I understand you correctly, when you hit Cancel, the edited item closes and RadGrid shows the regular item in view mode now with the wrongly updated values. If this is correct, then your data source has still been updated (even if wrong) and you cannot revert back to item's previous data values.

If this is not the case, and your data source is not wrongly updated, then calling RadGrid.Rebind() after you have reported the exception, should rebind the grid with the original data from your data source.

Sincerely yours,
Veli
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
Grid
Asked by
Albert
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or