Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default/Null vale for pulldown populated by query?

Status
Not open for further replies.
Oct 2, 2002
104
US
I have a dropdownlist with values that are populated by a sql query.

Can I have there be a --Please Select Value-- option, which, if none is selected, results in a null selection?

For instance: The DDL populates with
A
B
C

And I would like it to first have:
--Please Select Value--
A
B
C

Again, if no value is selected, it should be null.

Is this something I can set with the properties of the form, or would my query need to have this in it somewhere?
 
The line below will place this on top of the ddl.

ddlName.Items.Insert(0, new ListItem("--Please Select A Value-- "));

You could check the ddlName.SelectedIndex and if it is equal to zero act accordingly.
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top