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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList Populated from Database 2

Status
Not open for further replies.

dmears1

Technical User
Joined
Jun 18, 2003
Messages
208
Location
US
I'm populating a dropdownlist control from data in a database. This is working correctly. However, I'd like to add a list item for "Select Alll" as index 0. Is there a way to manually add list items even if you are using databinding? Any help is appreciated.

 
Yes, one method would be to actually add it to the data source itself (i.e. in the SQL). Alternatively, add a row to the DataTable (or whatever data control you are using) before binding.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks guys for the help. Got me pointed in the right direction. Here's what I came up with:

Code:
ddlCity.DataSource = SqlDataSourceJobs
            SqlDataSourceJobs.SelectCommand = "SELECT DISTINCT jobCity FROM jobs"
            ddlCity.DataBind()
            ddlCity.Items.Insert(0, "")
            ddlCity.Items.Insert(1, New ListItem("All", "*"))
            ddlCity.SelectedIndex = 0

Thanks again for the help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top