By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

validate dropdownlist

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jos
Cortvriend Andy wrote:
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)

--

Jos
Nov 18 '05 #2

P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Jos" <jo***************@fastmail.fm> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Cortvriend Andy wrote:
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)

--

Jos

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.