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

GridDropDownList Validation

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 18 May 2010, 05:21 PM
I have an issue validating GridDropDownList - it does not validate as other controls do. I have created a custom validator in the code behind but it does not fire when no value selected.


Thank you,

Steve O...

 

 

<telerik:RadGrid ID="RadGrid2"

 

runat="server"

 

GridLines="None"

 

DataSourceID="SqlDataSource11"

 

OnPageIndexChanged="dgIncidents_PageIndexChanged"

 

AllowAutomaticDeletes="True"

 

AllowAutomaticInserts="True"

 

AllowAutomaticUpdates="True"

 

OnItemInserted="RadGrid2_ItemInserted"

 

OnItemUpdated="RadGrid2_ItemUpdated"

 

OnDataBound="RadGrid2_DataBound"

 

AllowPaging="True"

 

ShowStatusBar="True"

 

AutoGenerateColumns="False"

 

Skin="Simple" >

 

 

 

 

 

 

<ValidationSettings CommandsToValidate="PerformInsert,Insert,Update,Delete"

 

EnableValidation="true" ValidationGroup="FormValidationGroup" />

 

 

 

 

 

------------------------------------------------------------------------------------------------------- 

 

 

 

 

<telerik:GridDropDownColumn DataField="UnitNameId"

DataSourceID="SqlDataSource3" DropDownControlType="DropDownList"

ListTextField="UnitName" ListValueField="UnitNameId" HeaderStyle-Font-Bold="true" UniqueName="UnitNameId"

HeaderText="Unit Name">

<HeaderStyle Font-Bold="True"></HeaderStyle>

</telerik:GridDropDownColumn>

 ----------------------------------------------------------------------------------------

 

GridDropDownColumnEditor editor = (GridDropDownColumnEditor)item.EditManager.GetColumnEditor("UnitNameId");

DropDownList ddl = (DropDownList)((Telerik.Web.UI.GridDropDownListColumnEditor)(editor)).DropDownListControl;

TableCell cell = (TableCell)ddl.Parent;

ddl.ID =

 

 

"UnitNameId";

 

 

ddl.AutoPostBack =

true;

 

ddl.CausesValidation =

 

 

true;

 

 

 

 

 

 

 


RequiredFieldValidator
validator = new RequiredFieldValidator();

 

 

 

validator.ControlToValidate = ddl.ID;

validator.ErrorMessage =

 

 

" * Unit Name Value Required";

 

 

cell.Controls.Add(validator);

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 19 May 2010, 08:19 AM
Hello Steve,

It seems that you are missing the validation group setting from RequiredFieldValidator declaration.

Regards,
Rosen
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.
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or