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

Assign ValidationGroup to RadGrid

3 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob Venable
Top achievements
Rank 1
Rob Venable asked on 12 Mar 2010, 11:07 PM
Hi,
I have a grid that is editable and I want to assign a ValidationGroup to the Delete and Update functionality so that it doesn't interfere with the other controls on the page. How do I set the ValidationGroup on these controls?
Here are my Edit and Delete Grid Command Columns:
<telerik:GridEditCommandColumn  ButtonType="ImageButton" UniqueName="EditCommandColumn">  
        <HeaderStyle HorizontalAlign="Center" Width="30px" /> 
        <ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" /> 
    </telerik:GridEditCommandColumn> 
    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" 
        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" 
        UniqueName="DeleteColumn">  
        <HeaderStyle HorizontalAlign="Center" Width="30px" /> 
        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
    </telerik:GridButtonColumn> 
I tried using ValidationGroup but it doesn't recognize it as a property for these columns. It happens when I hit the Delete column and when I hit the Update link after clicking the Edit column..

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Mar 2010, 09:21 AM
Hi,

Try the code snippet below to access  the controls for edit and delete accordingly:

C#
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editedItem = (GridEditableItem)e.Item; 
            ((ImageButton)editedItem.FindControl("UpdateButton")).ValidationGroup = "GroupA"
 
        } 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            ((ImageButton)dataItem["DeleteColumn"].Controls[0]).ValidationGroup = "GroupA"
        } 
    } 


Thanks,
Princy
0
Sörnt Poppe
Top achievements
Rank 1
answered on 07 Jan 2011, 09:04 PM
That is a design bug! I need to write code to set the ValidationGroup?

A much better way will be something like that:

        <telerik:GridEditCommandColumn                   
          ValidationGroup="GroupXY"
          ButtonType="ImageButton"
          />

Telerik - can you please fix that?
I see no reason why a ValidationGroup is needed for a delete buttom?

Kind regards,
Sörnt
0
Nikolay Rusev
Telerik team
answered on 11 Jan 2011, 09:59 AM
Hello Sörnt,

You can simply set:
<ValidationSettings EnableValidation="true" ValidationGroup="SomeGroup"/>

RadGrid will propagate the validation setting to all built-in buttons.

All the best,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Rob Venable
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sörnt Poppe
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or