Results 1 to 4 of 4

Thread: Populate A Dropdown From Another Dropdown

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    53

    Populate A Dropdown From Another Dropdown

    I have a page that has two dropdowns on it. When the page loads, the first box is populated from an Access table. Here's the tricky part for me...

    (Just when I think I understand how "postback" works, I find I'm wrong again!)

    I have the dropdown set to autopostback=true. When the user selects a choice in this dropdown, the page postsback (I think) and I want it to then query another table in the same database to fill the second dropdown list AND keep the original dropdown list's selection.

    For some reason, I can get it to fill the original dropdown, but then when it postsback, I get an error because my SQL statement to load the second dropdown looks like this:

    Dim objSeriesDA As New OleDb.OleDbDataAdapter("SELECT * FROM Series WHERE fldProviderID=" & lstProvider.SelectedItem.Value & " ORDER BY fldSeriesNumber DESC", objSeriesCN)
    Apparently, when the page postsback, the original dropdown list loses its selection, causing the SQL statement above to error out on a null reference.

    Any ideas?

    If need be, I can throw this up on a server so you all can see what I'm talking about... I can post the full source as well.

    Thanks!

    HWKY

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    wrap the code that is filling your first drop down list with this:

    If Not Page.IsPostBack Then
    '...your code here.
    End If

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    53
    Does anyone have a link to some information that explains PostBack in depth?

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    well, this link helped me with some basics on the page lifecycle when i was having user control postback problems. Really, there's not much more to the kind of postback stuff in your first post. If you know how the page loads and when control events are evaluated, that's pretty much it. Were you looking for information on how to roll your own PostBack handler or something else?

Posting Permissions

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



Click Here to Expand Forum to Full Width