Adding a "Select" option to a databound dropdown

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

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

Simo
 
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
 
Try this:

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

You can also create a ListItem object and pass that in place of the string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top