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

RadGrid ItemCommand custom validation

1 Answer 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 14 Jan 2013, 07:24 PM
I am using a RadGrid with a UserControl as my EditForm. I am doing some complicated custom validation when the ItemCommand is called on Update (e.CommandName = "Update") when a btn is clicked in the UserControl. I cannot use regular validation via one of the standard .net validation controls. My problem is that when my custom validation process is complete after the btn is clicked, I do not know how to keep the RadGrid in Edit mode with the UserControl / EditForm still exposed. I want to essentially keep the UserControl with the user's initial edits open with instructions for the custom validation, while being able to postback to do server validation.

How do I return to Edit mode within the ItemCommand event for CommandName == "Update"?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 17 Jan 2013, 02:32 PM
Hello,

Thank you for contacting us.

Generally, you can cancel the update command on server side which enables you to execute some custom logic before allowing the actual update operation:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.UpdateCommandName)
    {
        if (true) // condition
        {
            e.Canceled = true;
        }
    }
}

In addition, you can check out the following demo for a practical implementation of custom validator when editing RadGrid records:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/validation/defaultcs.aspx

I hope this will prove helpful. Please give it a try and let me know if it works for you.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or