I realize this is a late entry into this thread, but this
same requirement
came up for me today and in discussing various options
presented here and
discussion with our DBA, we have opted to use a UNION ALL
statement to
insert the "default" option into the results of
the SELECT statement.
The reason for opting for this method, is that if we ever
need to change the
text or values for the select, we can do so without having
to recompile and
deploy the web site, but will only need to change the values
in the stored
procedure in the database.
Here is a simple example to get a list of groups for a given
client with a
default option:
SELECT Group_ID,
[Name]
FROM tbl_Groups
WHERE Client_ID= Client_ID
UNION ALL
(Select 0, '--Selected a Group--')
ORDER BY Group_ID
The list.Add and List.Insert methods do work well, however.
Again, sorry for the late post.
Duane
-----Original Message-----
From: Lamprecht, Jan [mailto:JLamprecht1 fnb.co.za]
Sent: June 05, 2007 10:00 AM
To: aspnet aspadvice.com
Subject: [aspnet] A Blank entry in a DropDownList...
Hi All,
I have a question. Suppose I have a dropdownlist which is
bound to a dataset
and it has a few values in it...
The first time I display the form, I would have liked to
have a blank entry
in the dropdownlist - the blank being an indication that the
user has not
yet selected anything and that he must select something.
My problem is that I'm binding a dataset to the dropdown
list and the
dataset does not have a blank row in it.
How do I create a blank entry in a drop down list given the
above situation?
Do I have to add a blank record to the dataset that I'm
binding it with?
If so how do I do that?
Or, is there an option with dropdownlists for the control to
have a blank
option? (I've looked but can't find anything).
Or is there a better "conceptual" way of going
about this to begin with?
Thanks,
Jan
To read FirstRand Bank's Disclaimer for this email click on
the following
address or copy into your Internet browser:
https://www.fnb
.co.za/disclaimer.html
If you are unable to access the Disclaimer, send a blank
e-mail to
firstrandbankdisclaimer fnb.co.za and we will send you a copy of
the
Disclaimer.
--- List Settings ---
http://aspadvice.com/list
s/
--- List Settings ---
http://aspadvice.com/list
s/
|