CustomValidator on GridDropDown column doesn't work

1 posts, 0 answers
  1. Bob
    Bob avatar
    1 posts
    Member since:
    Apr 2015

    Posted 06 Feb 2017 Link to this post

    This code isn't firing the custom validator's ServerValidate event for my GridDropDown column.  The exact same code works fine if I hook it into a standard GridBoundColumn with an underlying TextBox control and the necessary underlying control type changes.

     

    protected void dtgFields_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem item = e.Item as GridEditableItem;

                GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)item.EditManager.GetColumnEditor("EDocFieldTagCtl");
                TableCell cell = (TableCell)editor.ComboBoxControl.Parent;

                CustomValidator validator = new CustomValidator();
                validator.ControlToValidate = editor.ComboBoxControl.ID;
                validator.ErrorMessage = "testing custom validator";
                validator.Display = ValidatorDisplay.Dynamic;
                validator.ServerValidate += new ServerValidateEventHandler(tagvalidate);
                cell.Controls.Add(validator);
            }
        }

Back to Top