DropDownList data not recognized

Coleen

Member
Joined
Jun 8, 2007
Messages
8
Programming Experience
1-3
Hi All :confused:
I am using VB.Net 2.0 - I have a dropdownlist I populate from an Access database - this works fine; however, when I try to use the SelectedItemChanged event, it does hit the sub routine, but it doesn't recognize the value of the ddl. I have:

VB.NET:
If ddlgeoregion.SelectedItem.Value.ToString() <> "" Then

               If ddlgeoregion.SelectedItem.Value.ToString() = "Africa" Then
                    lbl_msg.Visible = True
                    lbl_msg.Text = "Africa"
               End If
End If

Africa is exactly the same as it is in the DB - no spaces, but it isn't recognized so the code doesnt exicute. Any suggestions?

TIA,

Coleen
 
I don't know why this was moved here (it took me a bit to find it) this is NOT an ASP issue (as far as I can tell) it is a VB issue! In the code behind the value of the ddl is not being recognized. If this is an ASP issue, could someone please explain why? I can run the dbugger and it hits the selecteditem sub, and hits the first If statement but not the second, even though the value is identical. Any suggestions? TIA,

Coleen
 
Winforms doesn't have a DropDownList control, ASP.Net webforms does. You say you have a "dropdownlist", what control is that?

It took you a while to find!? The redirect link is exactly where you orignally posted this thread, and wears the same title you wrote.
 
The redirect was not immediately posted and I was searching for it. The issue is NOT in the ASP it is in the code behind! If you bothered to read the code snippet I sent you would see that the issue is in the nested If statement. The ASP control for the DDL works fine! That is NOT the issue! Please read posts before moving them. I will never get help on this issue if it's in the ASP Controls area - it is NOT a User control or Component issue! So, you distinguish VB code between ASP and windows users? What difference does it make if it is VB code that is not working correctly? Secondly, if you move my post to User Controls (user controls are typically created by a user to do something specific, such as a banner that can be re-used in multiple places) then the issue with my VB code will never get solved. Where do I post ASP VB code-behind related issues?
 
Last edited:
Hilarious. Webforms questions goes to ASP.Net section, it is usually significantly different from Winforms environment.

I will look into the issue tomorrow perhaps.
 
I don't know why this was moved here (it took me a bit to find it) this is NOT an ASP issue (as far as I can tell) it is a VB issue! In the code behind the value of the ddl is not being recognized. If this is an ASP issue, could someone please explain why? I can run the dbugger and it hits the selecteditem sub, and hits the first If statement but not the second, even though the value is identical. Any suggestions? TIA,

Coleen

Can you breakpoint on the second IF and then type this in the immediate window:

?ddlgeoregion.SelectedItem.Value.ToString() = "Africa"

If it says false, then ther is no way that the entity on the left hand side is equal to the right. type this:

?ddlgeoregion.SelectedItem.Value.ToString()


if it so much as comes out as:
"africa"

or
"Africa "

Then they arent the same, sorry..
 
I actually solved this Saturday and to be honest it was a dumb mistake on my part. I haven't programmed in 3 months - been on a leave of absence - but I found it and fixed it; it was the value (as you said) I of course tied the ddl into the key of the db and not the text, so of course it would never come back with "Africa" when the key value was 2. One of those "duh" moments!
 
Back
Top