By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,696 Members | 1,462 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,696 IT Pros & Developers. It's quick & easy.

drop down menu looses initial option

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
Not sure what you mean. Can you give me an idea of what the actual
correct code would be?

Apr 10 '06 #3

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.