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

Validation in RadGrid

4 Answers 658 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shubhadeep
Top achievements
Rank 1
Shubhadeep asked on 06 Nov 2013, 11:36 AM
Dear All,

In my application i want to add validation in insert and Update for some fields. Please let me know how to add validations in the grid. Also I have found the following code in the internet which is not working for me.
<telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" UniqueName="ShipName">
    <ColumnValidationSettings EnableRequiredFieldValidation="true" EnableModelErrorMessageValidation="true">
        <RequiredFieldValidator ForeColor="Red" ErrorMessage="This field is required"></RequiredFieldValidator>
        <ModelErrorMessage BackColor="Red" />
    </ColumnValidationSettings>
</telerik:GridBoundColumn>


In the above code snippet i am getting an error that the ColumnValidationSettings is not supported. Please help me.

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Nov 2013, 12:35 PM
Hello,

Can you please download latest version and check it?

In previous version this property is not supported. 

Please check below link for more information.
http://www.telerik.com/help/aspnet-ajax/grid-validation.html

Thanks.
Jayesh Goyani
0
Shubhadeep
Top achievements
Rank 1
answered on 06 Nov 2013, 12:37 PM
Dear Jayesh,

Thanks for your reply but i am unable to download the latest version because i am doing this project for my client and they provide this version q2 2011 and I have to work with the said version.
0
Princy
Top achievements
Rank 2
answered on 06 Nov 2013, 12:43 PM
Hi Shubhadeep,

You are getting such an error because your version of telerik doesn't support ColumnValidationSettings , please upgrade to the latest version, or try setting the validation from server side. Please go through this documentation on Validation .You can set ServerSide validation in ItemCreated event of the RadGrid as shown below.

C#:
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = e.Item as GridEditableItem;
        GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("ColumnUniqueName");
        TableCell cell = (TableCell)editor.TextBoxControl.Parent;
 
        RequiredFieldValidator validator = new RequiredFieldValidator();
        editor.TextBoxControl.ID = "ID_for_validation";
        validator.ControlToValidate = editor.TextBoxControl.ID;
        validator.ErrorMessage = "*";
        cell.Controls.Add(validator);
    }


Have a look and let me know if any concern.

Thanks,
Princy
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Nov 2013, 12:44 PM
Tags
Grid
Asked by
Shubhadeep
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Shubhadeep
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or