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

CustomValidator on GridDropDown column doesn't work

0 Answers 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 07 Feb 2017, 12:13 AM

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);
        }
    }

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Share this question
or