i have a standard grid with a series of columns in it i.e GridDropDownColumn, GridBoundColumn etc.
i want to know if there is a way of making the column a required field and validate it as such.
i know you can do it with a template column , but i dont want to have to create template columns for all the fields that require validation , there must be a simpler way to make a column a required field.
just to clarify this is for the insert/edit modes of the grid i need to validate the fields for.
thanks for your input on this.
5 Answers, 1 is accepted
But it's not working :( ,thay give error
Control 'CommunityNameID' referenced by the ControlToValidate property of '' cannot be validated.
My C# Coad is :
(e.Item is GridEditableItem && e.Item.IsInEditMode)
GridEditableItem item = e.Item as GridEditableItem;
DropDownList dropDownList1 = item["CommunityNameID"].Controls as DropDownList;
GridDropDownColumnEditor editor = (GridDropDownColumnEditor)item.EditManager.GetColumnEditor("CommunityNameID");
TableCell cell = (TableCell)editor.ContainerControl;
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ControlToValidate = editor.ContainerControl.ID;
And HTML Coad is
<telerik:GridDropDownColumn DataField="CommunityNameID" HeaderText="CommunityNameID"
UniqueName="CommunityNameID" HeaderStyle-Width="80px" DataSourceID="SqlDataSource2"
ListTextField="CommunityName" ListValueField="CommunityNameID" ColumnEditorID="CommunityNameID"
<ItemStyle HorizontalAlign="Center" Wrap="false" />
Plz Give me some idea for remove this error :)
To archive the desired functionality you need to use the following code snippet:
Additionally I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
1) use GridTemplateColumn instead, where you specify the ItemTemplate and EditItemTemplate, OR
2) use the programmatic solution above to create field validators and hook them up to the GridBoundColumn items
Indeed the described approaches are only way to have validation into the grid’s column. Unfortunately the RadGrid does not support declaratively adding a validation to the GridBoundColumn.
I hope this helps.
the Telerik team