Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present. The simple answer is that you don’t need any external list to bind to from C#, you can instead use the CultureInfo class.
Consider that you have the following dropdown list declared in an ASP.NET page:
Then from code-behind, call this method which binds the countries alphabetically to the dropdown:
public void BindCountries()
{
System.Collections.Specialized.StringDictionary dic = new System.Collections.Specialized.StringDictionary();
System.Collections.Generic.List col = new System.Collections.Generic.List();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
{
RegionInfo ri = new RegionInfo(ci.LCID);
...