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

Trying to validate GridDropDownColumn value

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kathy
Top achievements
Rank 1
Kathy asked on 21 Oct 2010, 06:03 PM
I'm pretty close on this one.  I took advantage of the EnableEmptyListItem to add an string telling the user to select an item.  I have a CompareValidator that is picking up the empty list item text.  What I would really like is to pick up the empty list item value, which is zero by default.  Here's what I have and it works on the text in the radcombobox.
GridDropDownListColumnEditor category = (GridDropDownListColumnEditor)item.EditManager.GetColumnEditor("RiskCategory");
                TableCell catcell = (TableCell)category.ComboBoxControl.Parent;
  
                CompareValidator comp = new CompareValidator();
                comp.ID = "compID";
                comp.ControlToValidate = category.ComboBoxControl.ID;
                  
                comp.ValueToCompare =  "Select a category";
  
                comp.Operator = ValidationCompareOperator.NotEqual;
                comp.ErrorMessage = "Please select a valid category";
                catcell.Controls.Add(comp);
Here, the emptylistitem text is "Select a category".  I can live with this, but if it's possible to get the value field for the comboboxcontrol, that would be great.  Thanks.

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 21 Oct 2010, 07:43 PM
Hello Kathy,

I believe if you use a RequiredFIeldValidator control, that it would pick up the empty list item.

I hope that helps.
Tags
Grid
Asked by
Kathy
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or