473,394 Members | 1,870 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,394 software developers and data experts.

drop down list

I have a drop down list that pulls the names of States from a database.

To this list I want to add "All", so the page will search all states.

how do I combine the manually-added "All" with the list of states from the
database?
Also how would i parse that so the sql string uses * or something

thanks

Oct 22 '06 #1
6 2677
"JP.Gantlin" <bi********@bitefdfme.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I have a drop down list that pulls the names of States from a database.

To this list I want to add "All", so the page will search all states.

how do I combine the manually-added "All" with the list of states from the
database?
You need the Items.Insert method of the DropDownList to add a new ListItem
at the index you specify...
Oct 22 '06 #2
at what point? Page load?

if i do that it loads "all" over and over with each page load
if i use this , it never laods it:

If Not IsPostBack Then

DropDownList2.Items.Insert(1, "All")

End If


Oct 22 '06 #3
"JP.Gantlin" <bi********@bitefdfme.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
at what point? Page load?
No - you should populate DropDownLists in Page_Init

DropDownList2.Items.Clear
DropDownList2.DataSource = <dataource>
DropDownList2.Items.Insert(1, "All")
Oct 22 '06 #4
thanks!!


Oct 22 '06 #5
Well that works on DropDownList1 (countries) *but* DropDownList2 (states)
no longer works

DropDownList2 pulls its data based on what is selected in DropDownList1 .
What do you think?

DropDownList1.Items.Clear()

DropDownList1.DataSource = SqlDataSource1

DropDownList1.DataBind()

DropDownList1.Items.Insert(0, "All")

DropDownList2.Items.Clear()

DropDownList2.DataSource = SqlDataSource2

DropDownList2.DataBind()

DropDownList2.Items.Insert(0, "All")
Oct 22 '06 #6
"JP.Gantlin" <bi********@bitefdfme.netwrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
Well that works on DropDownList1 (countries) *but* DropDownList2 (states)
no longer works

DropDownList2 pulls its data based on what is selected in DropDownList1 .
What do you think?

DropDownList1.Items.Clear()
DropDownList1.DataSource = SqlDataSource1
DropDownList1.DataBind()
DropDownList1.Items.Insert(0, "All")
DropDownList2.Items.Clear()
DropDownList2.DataSource = SqlDataSource2
DropDownList2.DataBind()
DropDownList2.Items.Insert(0, "All")
Well obviously not!

If the Items collection of the second DropDownList is dependent on the
selected item of the first, then you have three choices:

1) In Page_Init, query all the possible options for DropDownList2 and pump
them into a client-side JavaScript array. Then, when the selectedIndex of
DropDownList1 changes, repopulate DropDownList2 appropriately through
client-side JavaScript. Bigger hit when the page is loaded initially, but
avoids subsequent postbacks...

2) Wire up an OnSelectionChanged server-side event for DropDownList1, set
its AutoPostBack property to true, and requery the contents of DropDownList2
server-side. Much smaller initial hit, but will need a postback every time
the selectedIndex of DropDownList changes.

3) Use Ajax. Sort of a combination of the first two options...
Oct 22 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
by: pmelanso | last post by:
Hello, I have a drop down list which is dynatically loaded from a database and I have a second drop down list that is also dynatically loaded depending on what is selected in the first drop down...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
5
by: ashok893 | last post by:
I'm using two drop down list ina form. I have generated the first drop down list from MySQL database. When i select an option from first drop down list, i have to generate second drop down list...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
3
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.