validate dropdownlist

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
 
J

Jos

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)
 
P

Peter Blum

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top