Is there a class or library to get list of states for a given country?

8.2k Views Asked by At

Possible Duplicate:
Country, State, Province WebService?

This "orignal" link only shows web services or places I can get lists to insert manually. Does anyone know of a library / built in class / dll that wouldn't require hitting another server for the data and not require manual entry of each state?

I am currently adding support for Canada, Mexico, and Brazil, (and potentially more soon) to an ASP.NET website. The user can input their physical address including their state via drop down list. I currently have the US states added manually like:

states.Add(new ListItem("Alabama", "AL"));
states.Add(new ListItem("Alaska", "AK"));
etc ...

Before I go ahead and start manually creating lists for the additional countries, is there some pre-built class or library out there that can give me a list of states by passing it a country code? Example: someClass.getStatesFor("BR"); // would return a list/collection of states for Brazil.

2

There are 2 best solutions below

0
On BEST ANSWER

You may find the data you need on http://www.geonames.org. State information is referred to as administrative subdivision.

This data is available as a webservice, but you may also download it. The data description can be found on this page: http://download.geonames.org/export/dump/readme.txt

There are components for various languages, but I think those are to access the web services.

0
On

Here is an alternative: http://www.iso.org/iso/country_names_and_code_elements

The ISO list is always up-to-date.

Hope these help.