Use these steps to do so:-
1. It uses the System.Globalization Namespace to get all the cultures that are not only native on the system, but also all the ones installed with the .Net Framework. Add
using System.Collections.Generic;
using System.Globalization;
and then you can write the code like this to get all the countries into a list

2. The list comes as an unsorted one. We can implement a list sort function to sort this. But in my opinion the fastest method is to sort the control that is used to bind the list - in most cases it will be a dropdownlist obviously. So here is the fucntion to sort the dropdownlist.
Add
using System.Collections;
And now the below function to sort the dropdownlist

3. Now we are done. Use the functions like this
ddlCountry.Items.Add(country);
SortDDL(ref this.ddlCountry);
No comments:
Post a Comment