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

RadGrid - canceling update due to missing value

3 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 12 Aug 2016, 10:54 AM

Hello.

I have the Radgrid using a template edit form. How to cancel the on-going update, if the certain control doesn't have the appropriate value? I can reference the certain control in the template edit form and read it's new value (from within the "OnItemUpdated" event), but I don't know how to cancel the on-going update? On the update button I'am using CommandName="Update" Please advise.

 

Regards, E.

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 17 Aug 2016, 11:19 AM
Hello Erik,

Please try the following code snippet to cancel edit:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.EditCommandName) {
        GridDataItem item = (GridDataItem)e.Item;
        //Your switch case goes here
        //Example condition with if
        if (item("MyItem").Text == "Some Value") {
            e.Canceled = true;
        }
    }
}


Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Erik
Top achievements
Rank 1
answered on 20 Aug 2016, 06:11 AM

Hello Maria.

 

Thank you for your reply. But I need to cancel the allready "on-going" edit process on the "OK" submit button, which means that the update must be interrupted, if the updated value in the certain field wouldn't meet the requirements. Any suggestions?

Regards,

Erik

0
Accepted
Maria Ilieva
Telerik team
answered on 24 Aug 2016, 02:09 PM
Hello Erik,

The submit button should also fire ItemCommand event, which is leading to the same approach as the previously provided one. Give it a try and see if this works. If this does not help please share page markup and related code behind so that we can inspect your code locally and advise you further.

Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Erik
Top achievements
Rank 1
Share this question
or