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

Make GridEditCommandColumn skip validations

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Archana
Top achievements
Rank 1
Archana asked on 22 Jul 2011, 11:51 PM
Hi,

I have a page on which there are multiple tabs. Validations are checked on all tabs before you finally click Submit button on main page.
Now in one of the tabs I have radgrid which user should be allowed to edit at all times.
I'm able to make all items Editable on Edit command. But when I try to update it; it checks for all page validations.
Is there any way to set CausesValidation property to false for it or skip all the validations and update grid only?

I even followed below approach, Skipping valiadation was achieved but its not going inside 'image_Click' even after clicking on it.
protected void rgRequest_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem && e.Item.IsInEditMode)
            {
                GridDataItem item = (GridDataItem)e.Item;
                ImageButton image = (ImageButton)e.Item.FindControl("UpdateButton");
                image.CausesValidation = false;
                image.Click += new ImageClickEventHandler(image_Click);
            }
        }
Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 25 Jul 2011, 09:49 AM
Hello Archana,

This can be one way to circumvent the validation triggered by the buttons inside the RadGrid edit form. Note that instead of wiring the OnClick event of the image button, the more straight-forward option for your case would be to set its CommandName and intercept the relevant command inside the ItemCommand handler of the grid, namely:

protected void rgRequest_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 
        {
 
            if (e.Item is GridDataItem && e.Item.IsInEditMode)
 
            {
 
                GridDataItem item = (GridDataItem)e.Item;
 
                ImageButton image = (ImageButton)e.Item.FindControl("UpdateButton");
 
                image.CausesValidation = false;
 
                image.CommandName = "MyCommand";
                       //listen for this command (MyCommand) inside the ItemCommand handler of the grid 
 
            }
 
        }

Another means would be to put the internal grid validation mechanism into practice and configure it in par with your preferences. See this live demo for more details.

Kind regards,
Sebastian
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Archana
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or