Slae
Slae

Reputation: 345

Populate state/province dropdownlist according to country dropdownlist

Right now I have a method that fills the country dropdownlist using system.globalization. What I would like to know is if there is any way I'd be able to load the states/province of the country when a given country is selected.

 Public Sub fillCountryDDL()
        Dim objcountries As New List(Of String)()
        Dim objculture As CultureInfo() = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
        objcountries.Add(String.Empty)
        For Each getculture As CultureInfo In objculture
            Dim objregion As New RegionInfo(getculture.LCID)
            If Not (objcountries.Contains(objregion.EnglishName)) Then
                objcountries.Add(objregion.EnglishName)
            End If
        Next
        objcountries.Sort()
        ddlCountry.DataSource = objcountries
        ddlCountry.DataBind()
    End Sub

Is there something in system.globalization that handles this?

I've heard that one way to do this is by running a JS script. I'm currently attempting this, but have not been successful.

Upvotes: 0

Views: 831

Answers (1)

ascriven
ascriven

Reputation: 382

Unfortunately System.Globalization does not contain this information. You will have to find a different source for State/Province by country data.

This question talks about calling a webservice, or creating your own database to use. Getting States and Provinces in .NET

Upvotes: 1

Related Questions