A cascading dropdown for loading countries and associated states and local governments.
stable release version:
Nuget package downloads:
C#, .Net6.0, .NetStandard2.1 ,
First, install NuGet. Then, install CountryRegion from the package manager console:
NuGet \Install - Package CountryRegion - Version 1.0 .10 This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
Or from the .NET CLI as:
dotnet add package CountryRegion -- version 1.0 .10 Finally, import into the file:
Get all countries Get all states Get all local governments Get a country Get a state Get a local government Type Task<IEnumerable<Response?>>
await Region . GetStates ( countryId ) ; Parameter Type Description countryIdintRequired . The id of the country to get the states associated with it
Type Task<IEnumerable<Response?>>
await Region . GetLGAs ( countryId , stateId ) ; Parameters Type Description countryId,intRequired . The id of the country to get the local governments fromstateIdintRequired . The id of the state to get the local governments from
Type Task<IEnumerable<Response?>>
await Region . GetCountry ( countryId ) ; Parameter Type Description countryIdintRequired . The id of the country to get
await Region . GetState ( countryId , stateId ) ; Parameters Type Description countryId,intRequired . The id of the country to get a state fromstateIdintRequired . The id of the state to get
await Region . GetLGA ( stateId , lgaId ) ; Parameters Type Description stateIdintRequired . The id of the state to get local government fromlgaIdint?Required . The name of the local government in that state
GetState Extension Methodawait Region . GetState ( List < dynamic > objs , countryId , stateId ) ; Retrieves a specific state based on the provided parameters.
Parameters Type Description objsList<dynamic>Required . A list of objects representing the states.countryIdintRequired . The ID of the country to retrieve the state from.stateIdintRequired . The ID of the state to retrieve.
await Region . GetLGA ( List < dynamic > objs , stateId , lgaId ) ; Retrieves a specific Local Government Area (LGA) based on the provided parameters.
Parameters Type Description objsList<dynamic>Required . A list of objects representing the LGAs.stateIdintRequired . The ID of the state to retrieve the LGA from.lgaIdint?The ID of the specific LGA to retrieve (optional). If not provided, its assumed the state has no LGA
Thanks to all Contributors Maintainers:
Contributions are always welcome!
See contributing.md for ways to get started.
Please adhere to this project's code of conduct.