CustomValidator on GridCheckBox

4 posts, 0 answers
  1. Nancy Cara
    Nancy Cara avatar
    17 posts
    Member since:
    Feb 2008

    Posted 08 Feb 2008 Link to this post

    Control 'ValidatePhoneIsPrimary' referenced by the ControlToValidate property of '' cannot be validated.

    This is the error I get on my custom validator. If I change the validator to a different control to validate - like a textboxcontrol - then it works fine. But it won't work for my checkbox. 

    <telerik:GridCheckBoxColumn HeaderText="Primary" DataType="System.Boolean" DataField="IsPrimary" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None" UniqueName="PhoneIsPrimary">
    <HeaderStyle Width="10px" />

    protected void RadGrid1_ItemCreated1(object sender, GridItemEventArgs e)


    if (e.Item.OwnerTableView.Name == "Phone")
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                GridEditableItem item2a = e.Item as GridEditableItem;

    GridCheckBoxColumnEditor editor2a = (GridCheckBoxColumnEditor)item2a.EditManager.GetColumnEditor("PhoneIsPrimary");

    TableCell cell2a = (TableCell)editor2a.CheckBoxControl.Parent;

    CustomValidator validator2a = new CustomValidator();

    editor2a.CheckBoxControl.ID =


    validator2a.ControlToValidate = editor2a.CheckBoxControl.ID;

    validator2a.ErrorMessage =

    "Inactive or Closed Phone can not be Primary Phone";

    validator2a.ServerValidate +=

    new ServerValidateEventHandler(CustomValidator1_ServerValidate);




    protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)


    if (args.Value == "0"){args.IsValid = true;}}

    If I can get this working I will also need to look at and compare args.value to my combobox dropdown selected value - I am not sure how to retrieve that value here in my validation routine.

  2. Nancy Cara
    Nancy Cara avatar
    17 posts
    Member since:
    Feb 2008

    Posted 13 Feb 2008 Link to this post

    Unfortunately none of that information addresses my problem. I think it is a bug with trying to assign a validation event to a 

    GridCheckBoxColumnEditor because like I said, it works fine for  GridTextBoxColumnEditor and GridMaskedColumnEditor

  3. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 14 Feb 2008 Link to this post


    There are some server controls for which Custom validator can't be applied. CheckBox control is one such control. Custom validator eases the validation logic written by the developer. When I had a requirement in my project to validate the CheckBox control, I Googled and found the following article:

    <John:Peel />
Back to Top