0

I have two Tables in my database

1)Countryddl

Countryid       Countryname
1                India
2                USA
3                Australia

2)stateddl

Stateid     Countryid     Statename
1           1             Delhi
2           1             Mumbai
3           2             New York
4           2             Chicago
5           3             Perth
6           3             Melbourne

I have two drop downs in view,

Then How to bind 1st table to 1st drop down and 2nd table to 2nd using countryid

Nilesh Thakkar
  • 1,442
  • 4
  • 25
  • 36
  • 1
    You need to use javascript/jquery to handle the `.change()` event of the first dropdown to call a controller method that returns the states based on the selected country. Refer [this answer](http://stackoverflow.com/questions/28627421/better-way-to-load-2-dropdown-in-mvc/28640420#28640420) for an example –  Jul 31 '15 at 06:03

1 Answers1

0

1, write 2 actions,1 return all contry,then click contry,begin ajax to second action and pass the contry id,second action return state,and show on page
2,write a big model with all contry and all state in contry,pass the model to view and save it by js array.when click contry,search the contry in js array and show the contry state

chenZ
  • 920
  • 4
  • 16