Monday, August 16, 2010

ASP.NET : GridView : Adding two dropdown boxes?




I have this problem that I really want someone to help me with.





I have a GridView that should show some data (name, country and city).





When editing, I have configured the Country and City to display their data in dropdown boxes. And it's working fine. The countries and cities dropdowns retrieve their data from two tables called Countries and Cities.





My problem is, how can I link the Country to the City ! I mean, when I try to change the country, I want the cities to be updated so that I can see only relevant cities to the selected country.





I have searched a lot for a solution, with no hope !





Can anyone help?





If you can, just explain with Code .. Or e-mail me the solution on yasserhy AT yahoo.com ..





Thank youASP.NET : GridView : Adding two dropdown boxes?
My guess would be that you would have to have individual tables for each Country. For example US, Mexico, and Canada would have their own cities in a table. Then you may have to write an if statement for where the Cities drop down is getting the data from. I haven't coded in a while but that's how I would do it.





If it's SQL you could write a query to pull from the Cities table where Country is XXXXX. That would pull only the cities from the Country specified from the Countries drop down.

No comments:

Post a Comment