Cascading dropdownlist - page life cycle

Discussion in 'ASP .Net' started by Jacques, Dec 6, 2007.

  1. Jacques

    Jacques Guest

    Platform: .Net v2.0 Asp.net

    Scenario: Three dropdownlist controls on a user control. In consecutive
    order they are Countries, Regions, Cities. Countries is loaded during OnInit
    and the other two are left disabled. Once the user selects a country, the
    regions list is populated. Once a region is selected the cities list is
    loaded.

    Problem: When it comes to the page life cycle, there doesn't seem to be an
    appropriate place to put the code to load the second and third list. To load
    the list of regions you need the selected value of the countries
    dropdownlist. You will only have this information during and after OnLoad.
    It will work to load the list of Regions at this point, but viewstate and
    postback data will no longer work, because it has already been processed by
    the time the list is attempting to load.

    Question: What is the best way to achieve this kind of cascading
    dropdownlist whilst keeping the page life cycle happy?

    Thanks
     
    Jacques, Dec 6, 2007
    #1
    1. Advertising

  2. Jacques

    bruce barker Guest

    in oninit you should load the dropdowns based on viewstate or session if
    not using viewstate. in onload or onchange you reload based on postback
    values.

    -- bruce (sqlwork.com)

    Jacques wrote:
    > Platform: .Net v2.0 Asp.net
    >
    > Scenario: Three dropdownlist controls on a user control. In consecutive
    > order they are Countries, Regions, Cities. Countries is loaded during OnInit
    > and the other two are left disabled. Once the user selects a country, the
    > regions list is populated. Once a region is selected the cities list is
    > loaded.
    >
    > Problem: When it comes to the page life cycle, there doesn't seem to be an
    > appropriate place to put the code to load the second and third list. To load
    > the list of regions you need the selected value of the countries
    > dropdownlist. You will only have this information during and after OnLoad.
    > It will work to load the list of Regions at this point, but viewstate and
    > postback data will no longer work, because it has already been processed by
    > the time the list is attempting to load.
    >
    > Question: What is the best way to achieve this kind of cascading
    > dropdownlist whilst keeping the page life cycle happy?
    >
    > Thanks
    >
    >
     
    bruce barker, Dec 6, 2007
    #2
    1. Advertising

  3. Jacques

    Jacques Guest

    We're not using viewstate so that's not an option.

    Could you explain your session method in a bit more detail?

    Cheers
    Jacques
     
    Jacques, Dec 7, 2007
    #3
  4. Jacques

    Adam Mather Guest

    RE: Cascading Dropdownlist

    What was your solution to this problem in the end Jacque?.

    I am attempting to re-write an ASP / VB Script application in C# to be made available as a series of web parts to be deployed on WSS 3.0.

    I have a form which has three dropdownlists. similar to your senario i require the first dropdownlist to populate the second and the second dropdownlist to populate the third.

    i have tackled this problem in many different ways and am still failing miserably in my quest.

    time is of the essence here - please can you guide me in the right direction?
     
    Adam Mather, Jun 13, 2008
    #4
    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 Rilling
    Replies:
    5
    Views:
    361
    Peter Rilling
    Mar 9, 2005
  2. Guest
    Replies:
    3
    Views:
    2,789
    Bruce Barker
    Sep 6, 2005
  3. Fred
    Replies:
    5
    Views:
    6,253
    Karl Seguin [MVP]
    Jan 23, 2006
  4. lander
    Replies:
    5
    Views:
    2,540
    Mark Rae [MVP]
    Mar 3, 2008
  5. Gary Larimer

    Page life cycle and Page.IsValid property

    Gary Larimer, Jul 30, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    386
    Gary Larimer
    Aug 1, 2008
Loading...

Share This Page