473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

validate dropdownlist

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
2 3082
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Newbie | last post by:
i need to validate a dropdownlist (ddlState) in a c# asp.net webform. in other words, i need to make sure that the user selects an item in the dropdownlist. it contains the items: Items ...
1
by: Reddy | last post by:
Hi, My web form has a dropdown list and a textbox server controls. The user must enter some text in the textbox he selects only the last item in the dropdownlist. I tried using a custom...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
5
by: gane kol | last post by:
Hi I have a custom validator that validates a dropdownlist with a listitem value as "". But the clientvalidation function is never called. but if i use value = "0" and check it in javascript, it...
2
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the...
2
by: js | last post by:
hi, how to validate if dropdownlist value is empty? many thanks.
2
by: bobby421 | last post by:
have to validate my web page using java script. I have one dropdown list also . I need a javascript to validate weather any item in dropdownlist is selected or not. e.g ddlDrop is my dropdownlist. ...
0
by: shapper | last post by:
Hello, I have 3 DropDownLists: ddlA, ddlB and ddlC. All these DropDownLists have a item which value is "". I need to create a validator that fires if any of the ddls are empty. I tried to...
18
by: Redhairs | last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event during the postback?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.