|
Subject:
|
Populate multiple dropdowns without postback?
|
|
Posted By:
|
jamesb2001
|
Post Date:
|
10/11/2004 11:38:59 AM
|
Hi, I have a webform with four dropdown lists, each of which (apart from the first one obviously) must be populated after a choice is made in the one before it.
I want to avoid postbacks as much as possible as this isn't pleasant for the user (at least not 3 times in a row) - is there a technique (involving a dataset with multiple tables I would guess) that will allow me to do this without postback?
Example of what I mean:
User chooses "Europe" in first dropdown, and second list instantly only contains countries in Europe, user chooses England, and third list instantly lists only cities in England etc
The dropdowns are of course related at the database end - as I understand it a dataset can contain related tables?
This must be a common requirement, but my searches so far have turned up very little!
Thanks for any help :)
|
|
Reply By:
|
Santhi
|
Reply Date:
|
10/11/2004 12:32:21 PM
|
I think we can;t populate the value of the dropdown without submitting the page in your case. We can do this scenario using JavaScript on the client side if we hardcode the country names..
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
10/11/2004 12:46:19 PM
|
You can use mutiple tables, however, creating relations won't help unless you post back. In the drop down's SelectedIndex_Changed event, you can loop the the appropriate table(s) and add the values to your dropdown by usingthe ddl<name>.Items.Add method. However, you have to remember to remove the items from the list if any when the index is changed with the ddl<name>.Items.Clear method.
|