validate dropdownlist

  • Thread starter Thread starter Cortvriend Andy
  • Start date Start date
C

Cortvriend Andy

hi

i'm filling an dropdownlist with data from sql server
now i want to validate if a selection have been made
the problem is that the validator never shows up
i think he always says that something is selected
Anyone who can help me ???
thx
 
Cortvriend said:
hi

i'm filling an dropdownlist with data from sql server
now i want to validate if a selection have been made
the problem is that the validator never shows up
i think he always says that something is selected
Anyone who can help me ???
thx

By default, the first item in a dropdownlist is always
selected.

2 solutions:
1) Use a ListBox instead
2) Add a dummy first item, and force the user to select another item with a
custom validator or a range validator (when your values are numbers)
 
Microsoft's RequiredFieldValidator is designed to detect that a listbox has
no selection. If you actually want to make the first item of the list be
selected and say "Make a selection", you can validate that with these steps:
1. Set the ListItem.Value to "noselection"
2. Use a RequiredFieldValidator
3. Set RequiredFieldValidator.InitialValue = "noselection"

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top