473,473 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

drop down menu looses initial option

I have a drop down menu which has a list of subcategories and the
initial value is "please choose a Subcategory". When the user chooses a
subcategory they are taken to a new page where the drop down list shows
the selected subcategory in the menu. So far that is working.

The problem is that when the list is showing the subcategory on the
second page there are now two of that item in the list and the initial
item that should be available in the drop down is missing.

In other words in the initial drops down the user has the following
options,.
Choose a subcategory
shoes
boots
slippers

The user chooses boots

Then on the following page which is the boots subcategory the list
looks like this.

boots
boots
slippers

I would love some help. Here is the code:

---------------------------------------------------------------------------------

'The Department for which we are loading the categories

Dim BrandID As String = Request.QueryString("brandID")
Dim CategoryID As String = Request.QueryString("CategoryID")
Dim strSubCategory As String =
Request.QueryString("strSubCategory")

'choosing if it is a brand or category - each pulls from a different
database table

If Not IsPostBack Then
If Not CategoryID Is Nothing Then

list.DataSource = Catalog.GetSubCatsinCats(CategoryID)
list.DataBind()
'lblsubnav.Text = CategoryID

'If there is no subcategory in the querystring then you have the
"Please choose a subcategory" and the initial list. Otherwise you
have the selected item showing

HERE IS THE PROBLEM!

If Not strSubCategory Is Nothing Then
list.SelectedItem.Text = strSubCategory
Else
list.Items.Insert(0, "Please choose a subcategory")
End If
'repeats for brands

ElseIf Not BrandID Is Nothing Then
list.DataSource = Catalog.GetSubCatsInBrands(BrandID)
list.DataBind()
If Not strSubCategory Is Nothing Then
list.SelectedItem.Text = strSubCategory
Else
list.Items.Insert(0, "Please choose a subcategory")
End If
Else

' lblsubnav.Visible = False
list.Visible = False
' label.Visible = False

End If
End If
-----------------------------------------------------------------

Apr 10 '06 #1
4 1503
If Not strSubCategory Is Nothing Then
You are subtituting shoes for boots !?! <<<

list.SelectedItem.Text = strSubCategory
Else
list.Items.Insert(0, "Please choose a subcategory")
End If

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"Laura K" <kl*****@charter.net> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...I have a drop down menu which has a list of subcategories and the
initial value is "please choose a Subcategory". When the user chooses a
subcategory they are taken to a new page where the drop down list shows
the selected subcategory in the menu. So far that is working.

The problem is that when the list is showing the subcategory on the
second page there are now two of that item in the list and the initial
item that should be available in the drop down is missing.

In other words in the initial drops down the user has the following
options,.
Choose a subcategory
shoes
boots
slippers

The user chooses boots

Then on the following page which is the boots subcategory the list
looks like this.

boots
boots
slippers

I would love some help. Here is the code:

---------------------------------------------------------------------------------

'The Department for which we are loading the categories

Dim BrandID As String = Request.QueryString("brandID")
Dim CategoryID As String = Request.QueryString("CategoryID")
Dim strSubCategory As String =
Request.QueryString("strSubCategory")

'choosing if it is a brand or category - each pulls from a different
database table

If Not IsPostBack Then
If Not CategoryID Is Nothing Then

list.DataSource = Catalog.GetSubCatsinCats(CategoryID)
list.DataBind()
'lblsubnav.Text = CategoryID

'If there is no subcategory in the querystring then you have the
"Please choose a subcategory" and the initial list. Otherwise you
have the selected item showing

HERE IS THE PROBLEM!

If Not strSubCategory Is Nothing Then
list.SelectedItem.Text = strSubCategory
Else
list.Items.Insert(0, "Please choose a subcategory")
End If
'repeats for brands

ElseIf Not BrandID Is Nothing Then
list.DataSource = Catalog.GetSubCatsInBrands(BrandID)
list.DataBind()
If Not strSubCategory Is Nothing Then
list.SelectedItem.Text = strSubCategory
Else
list.Items.Insert(0, "Please choose a subcategory")
End If
Else

' lblsubnav.Visible = False
list.Visible = False
' label.Visible = False

End If
End If
-----------------------------------------------------------------

Apr 10 '06 #2
Not sure what you mean. Can you give me an idea of what the actual
correct code would be?

Apr 10 '06 #3
OK fixed it a bit but now I have a new problem. I changed

list.SelectedItem.Text = strSubCategory
to

list.Items.Insert(0, strSubCategory)

This works fine except I get the text twice. Once on the top of the
list where the user can see it when the page loads and a second time in
the list itself where it nornally is.

Apr 10 '06 #4
The problem is that your sub catagory is the same name as the first item in
the list. You dont need to add this at all as far as I can see as once you
have selected the subcategory, you now have the list ( of sub categories )
that you need,so Im not sure why are you trying to add it in ?

Unless I have misunderstood you ?

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"Laura K" <kl*****@charter.net> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
OK fixed it a bit but now I have a new problem. I changed

list.SelectedItem.Text = strSubCategory
to

list.Items.Insert(0, strSubCategory)

This works fine except I get the text twice. Once on the top of the
list where the user can see it when the page loads and a second time in
the list itself where it nornally is.

Apr 11 '06 #5

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

Similar topics

4
by: Mike Wilcox | last post by:
I use the following code snippet to build a drop down menu with the results of a query. How can I set the initial value of this input based on the result of another query? What I am trying to do...
6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
19
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu....
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
2
by: Boujii | last post by:
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu,...
1
by: Kaland | last post by:
Do the search engines follow links that are within forms (like the drop-down menu) so that those pages are indexed? Here is the code for a sample drop-down menu that I created. <form><select...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.