RadGrid - canceling update due to missing value

4 posts, 1 answers
  1. Erik
    Erik avatar
    3 posts
    Member since:
    Jul 2014

    Posted 12 Aug Link to this post

    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.

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 17 Aug Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Erik
    Erik avatar
    3 posts
    Member since:
    Jul 2014

    Posted 20 Aug in reply to Maria Ilieva Link to this post

    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

  5. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Aug Link to this post

    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.
Back to Top