Click here to Skip to main content
15,916,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am trying to bind data with 2 dropdowns.

I am having 2 tables :
1)country:
country_id(primary key)
country_name
2)state:
state_id(primary key)
state_name
country_id(foreign_key)


now i tried to bind the data with 2 dropdown list
ddp1 and ddp2.
such that when i select the country from first dropdown(ddp1) then the state corresponding to that country should come in the second dropdown(ddp2).

Can some one please help me .

Thanks .
Posted

You are talking of a Cascading Dropdown. Just Google/CP Search for it.

What you are looking for is populating a second dropdown based on the value selected in first dropdown.
Earlier it was Server side, then traditional AJAX==XMLHttpRequest. Now, we can use Update panel or PageMethod for it.

If not anything else, Ajaxtoolkit has a cascading dropdown[^] control.

Look at this article too:
AJAX Cascading Dropdown Example using SQL Database[^]
 
Share this answer
 
Thanks for your reply.....

I was thinking this to do with c# as i am not much familiar with ajax. And i have to show my project by doing the same.
 
Share this answer
 
Comments
r verma 7-Apr-11 23:04pm    
In case you do not want to use AJAX ToolKit as suggested in last reply then you have to write traditional code like when user will select country from first drop down then you will again query for fetching cities corresponding to that country and populate second drop down.
You'll write complete logic through SelectedIndex change event of first drop down and may prefer an AJAX update panel.
thanks for your reply...........:-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900