473,387 Members | 1,453 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.

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

Similar topics

3
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I...
3
by: J. Muenchbourg | last post by:
I have an ASP admin script where I'm adding records, and I have a category that already has set name values hard-coded into a selct option pulldown, but if the user wants to create a new category...
11
by: Stefan Finzel | last post by:
Hi trying to remove one or all elements of select options fails for Pocket Internet Explorer. Is there a way to do this? if is_PIE { // this does not work on Pocket IE while (opt.length) {...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
2
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
2
by: wink martindale | last post by:
Hello, I am creating a vb.net app, using a mysql db. I am connecting to the db, and filling some dropdowns with data. My quesiton is: How can I make the first item (default item) in the...
2
by: Simon Harvey | last post by:
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...
1
by: rvelosoo | last post by:
Hi, I'm having trouble selecting an option in html, i.e. i change the code, but the change is not reflected in the browser. Example, i have <select> <option>A <option selected>B </selected>
3
by: yawnmoth | last post by:
//form//input //form//select//option I can combine those with an or (|), but to make my code more concise, would it be possible to reuse the //form bit? Could I maybe do something like this,...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.