Hi
I have a grid with a GridDropDownColomn and i tried to add a requiredFieldValidator to it, but it seems that i"m missing something.... First i use RadGrid1_ItemDataBound to add a "Please select item" in my RadComboBox, after that in the RadGrid1_ItemCreated, i'm looking for my radcombo and i associate the RequiredFieldValidator to it but it does'nt works. I assume that the requiredFieldValidator check for the selected text and not the value , so how i can make it works ? There is my code snippet :
Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If
TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim Combo As RadComboBox = TryCast(e.Item.FindControl("RCB_ResponsibleID"), RadComboBox)
Combo.Items.Insert(0,
New RadComboBoxItem(Resources.Resources.GRID_SELECT_RESPONSIBLE, Nothing)
End If
End Sub
Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
Dim Combo As RadComboBox = TryCast(Item("ResponsibleID").FindControl("RCB_ResponsibleID"), RadComboBox)
Dim ResponsibleValidator As New RequiredFieldValidator
ResponsibleValidator.ControlToValidate = Combo.ID
ResponsibleValidator.InitialValue =
Nothing
ResponsibleValidator.SetFocusOnError = True
ResponsibleValidator.ErrorMessage = Resources.Resources.GRID_MUST_SELECT_RESPONSIBLE
Cell = Combo.Parent
Cell.Controls.Add(ResponsibleValidator)
End If
End Sub
Thanks in advance for your helps !