SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How Do I Enable A Drop Down List When Another Drop Down List Item Is Selected

    I am attempting to enable a drop down list when an item is selected in another drop down list.

    Here is my code:

    Protected Sub ddlDepartment_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlDepartment.SelectedIndexChanged
    ddlDivision.Enabled = True


    End Sub


    But it does not enable the other drop down list. What do I need to do?

    Thanks.

    Chris S.

  2. #2
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,619
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    That's not html or css code

  3. #3
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's VB.NET.

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    When you select a value in the first drop down, is the page performing a postback or just sitting there? If it isn't performing a postback, that is why, you haven't registered the event you defined with the control yet, and that needs to happen.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    When you select a value in the first drop down, is the page performing a postback or just sitting there? If it isn't performing a postback, that is why, you haven't registered the event you defined with the control yet, and that needs to happen.
    The page does not flicker and I don't have the control in an update panel, so I have to say that it does not do a postback. What do I need to do to force it too?

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Within the aspx file there are two properties you can set. AutoPostBack (needs to be true), and OnSelectedIndexChanged (needs to have ddlDepartment_SelectedIndexChanged)
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  7. #7
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I click on the drop down, it works, but when I select the first drop down list box, it always go back to the first item in the list no matter what I select.

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    I'm not following, can you provide a few screenshots?
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  9. #9
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    I'm not following, can you provide a few screenshots?
    I uploaded a video on YouTube. There is no sound but you can see that when I click on the item in the drop down no matter what it is, the first item is displayed.
    Here is the link: http://youtu.be/gIbbCdZJZVM

  10. #10
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    hmmm... That's weird. Also, it still doesn't seem to be performing a post back (at least in the video it didn't post back...)
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  11. #11
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    See the attached example (very simplified), I provided it in both C# and VB.
    Projects.zip
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  12. #12
    SitePoint Zealot cruncher06's Avatar
    Join Date
    Feb 2009
    Location
    Illinois, USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cpradio, your original solution worked. The reason that the same value displayed was because I selected the wrong field in my database. That field only had three unique records. So it would select the first from a series of records. After referencing the right field, everything works as well as the postback. Thanks for the help.

  13. #13
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Glad to hear it.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •