Cascading dropdownlist - page life cycle

  • Thread starter Thread starter Jacques
  • Start date Start date
J

Jacques

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
 
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)
 
We're not using viewstate so that's not an option.

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

Cheers
Jacques
 
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?
 
Back
Top