Dropdown list - SelectedIndexChanged event doesn't fire

Discussion in 'ASP .Net' started by Guest, Mar 14, 2005.

  1. Guest

    Guest Guest


    I have a dropdown list on a user control and the AutoPostBack property is
    set to True. I want to use the SelectedIndexChanged event to populate some
    text boxes based on what the user chose in the dropdown list.

    However, the SelectedIndexChanged event doesn't fire. In the immediate
    window it appears that the index is not changing when I select a different
    option in the list.

    After wrestling with this for a couple hours, I think it has to do with the
    fact that I am loading the list options from the database:

    sql = "SELECT Code, Description FROM luApptType"
    ds = clsDB.GetDataSet(sql)
    With Me.lstApptType
    .DataSource = ds
    .DataTextField = "Description"
    .DataValueField = "Code"
    .Items().Insert(0, New ListItem(""))
    End With

    The code above is contained in a LoadLists function that is called in the
    first Page Load:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    End If
    End Sub

    When I try this with a second dropdown where the options are hard-coded, the
    SelectedIndexChanged event fires as expected. No problems.

    Can you tell me why it's not working with the first dropdown where the
    options are loaded at runtime?

    Thanks -- I'm at my wit's end!
    Guest, Mar 14, 2005
    1. Advertisements

  2. Guest

    Guest Guest

    Please disregard my earlier post. I had a coworker take a look at it, and on
    the first run-through, it magically started working.
    Guest, Mar 14, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.