Autopostback dropdownlists...

Discussion in 'ASP .Net Web Controls' started by Dan Bass, May 18, 2007.

  1. Dan Bass

    Dan Bass Guest

    Greetings!

    I've two dropdownlists where each has its own sqldatasource object as a
    datasource.

    The first, for example, contains a list of car manufacturers... BMW, Audi,
    Peugeot, Ford, etc...
    The second then changes to the viable models based on the selection of the
    first dropdown selection. So if the user selects BMW, then it displays
    '116, 118d, 118, 120, 316... etc'.

    Grand, peace of cake.


    Now, I save this data to a database and allow the users to load up the form
    later on. The problem is, I populate and select the loaded item from first
    dropdownlist (in Page_Load), but this doesn't populate the second
    dropdownlist with the sublist as would happen on an autopostback. So in our
    example, BMW is selected from the dropdownlist, but this doesn't then
    refresh the query on the 2nd sqldatasource or dropdownlist to see models in
    the BMW range. I've tried called DataBind, but this doesn't seem to do
    anything.


    Hope this isn't too muddy. Any help is appreciated.
    Thanks.
    Dan.
    Dan Bass, May 18, 2007
    #1
    1. Advertising

  2. Well. the problem is that if the 2nd SqlDataSource has a query tha is only
    designed to populate all the items, then it will be too "Dumb" to know what
    to do when an item is selected from the first guy. During the
    SelectedIndexChanged event of the first, you need specific code to set the
    selected item on the second, or bring in fresh data and databind it so it
    matches the ID of the item selected from the first guy.
    Peter
    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "Dan Bass" wrote:

    > Greetings!
    >
    > I've two dropdownlists where each has its own sqldatasource object as a
    > datasource.
    >
    > The first, for example, contains a list of car manufacturers... BMW, Audi,
    > Peugeot, Ford, etc...
    > The second then changes to the viable models based on the selection of the
    > first dropdown selection. So if the user selects BMW, then it displays
    > '116, 118d, 118, 120, 316... etc'.
    >
    > Grand, peace of cake.
    >
    >
    > Now, I save this data to a database and allow the users to load up the form
    > later on. The problem is, I populate and select the loaded item from first
    > dropdownlist (in Page_Load), but this doesn't populate the second
    > dropdownlist with the sublist as would happen on an autopostback. So in our
    > example, BMW is selected from the dropdownlist, but this doesn't then
    > refresh the query on the 2nd sqldatasource or dropdownlist to see models in
    > the BMW range. I've tried called DataBind, but this doesn't seem to do
    > anything.
    >
    >
    > Hope this isn't too muddy. Any help is appreciated.
    > Thanks.
    > Dan.
    >
    Peter Bromberg [C# MVP], May 18, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter J. Hunter

    Positioning in dropdownlists

    Peter J. Hunter, Jan 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    509
    Peter J. Hunter
    Jan 14, 2004
  2. Craig Buchanan

    parent child dropdownlists acting oddly

    Craig Buchanan, Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    Craig Buchanan
    Jun 27, 2003
  3. Darren

    Multiple DropDownLists

    Darren, Aug 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Steve C. Orr, MCSD
    Aug 18, 2003
  4. Dan Bass

    Autopostback dropdownlists...

    Dan Bass, May 18, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    315
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    May 18, 2007
  5. Stephen Balkum

    DropDownLists, AutoPostBack and the back button

    Stephen Balkum, Sep 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    488
    Jacob Yang [MSFT]
    Sep 17, 2003
Loading...

Share This Page