In my registeration form i have fields named country and city. I want that i select a country lets say USA then city field should show all the cities in USA.
i know that i have to put all the cities in Database and then bind it to dropdown box , putting IF statements etc blah blah !!!
but isn't there some alternative to do it , to save time ? it would take alot of time to code. HELP !!!

Recommended Answers

All 2 Replies

You don't have to be lazy. Thats the best practice, Thats the demand of coding. You would need to create 2 tables, one for the city and another for the country. You obviously need to link up the 2 tables by having the primary key of country table as a forein key in the city table.

after that you want to bind your country drop down with the data from country and you also want to enable the autopostback property of your drop down.
you will then have to bind data on the city drop down in the index changed event of the country drop down. Makes sense?

awesome !!! i had kinda idea about that but you made it clear !!! thanks !!!
and sorry , i didn't mean to be lazy but i have a very shoert time to submit my project, (fianl year project) and i coded alot. so making shortcuts for things like this!!! but doesn't matter, as u said, i vl code it. Thanks !!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.