471,598 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Adding a "Select" option to a databound dropdown

Hi all,

I have to use drop downs in a number of places in my applications. These
drop downs are databound but I can't seem to see how to add a new item (eg
"Select" or something like that) to the beginning of the drop down.

I obviously dont want to have to put dodgy data like that in the database
but I'm sure there is an easier solution.

Can anyone help?

Many thanks

Simon
Jan 18 '06 #1
2 2859
Simon,
There are other ways, but what I usually do is just before setting the
datasource, I add a DataRow with "Please Select" using DataTable.Rows.InsertAt
Usually I cache stuff like this anyway so it only needs to be done once.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simon Harvey" wrote:
Hi all,

I have to use drop downs in a number of places in my applications. These
drop downs are databound but I can't seem to see how to add a new item (eg
"Select" or something like that) to the beginning of the drop down.

I obviously dont want to have to put dodgy data like that in the database
but I'm sure there is an easier solution.

Can anyone help?

Many thanks

Simon

Jan 18 '06 #2
Try this:

DropDownList1.Items.Insert(0, "Select <something>");

You can also create a ListItem object and pass that in place of the string.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"Simon Harvey" <no******@hotmail.com> wrote in message
news:7c**************************@news.microsoft.c om...
Hi all,

I have to use drop downs in a number of places in my applications. These
drop downs are databound but I can't seem to see how to add a new item (eg
"Select" or something like that) to the beginning of the drop down.

I obviously dont want to have to put dodgy data like that in the database
but I'm sure there is an easier solution.

Can anyone help?

Many thanks

Simon

Jan 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Stefan Finzel | last post: by
2 posts views Thread by wink martindale | last post: by
2 posts views Thread by Simon Harvey | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

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.