Cascading dropdownlist - page life cycle

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
 
B

bruce barker

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)
 
J

Jacques

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

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

Cheers
Jacques
 
A

Adam Mather

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?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top