I wish to force danish culture in my web application, but I can not get it work. I am trying to populate a dropdown list with danish country names, but they return in english.
public static IEnumerable<SelectListItem> GetCountries(string selectedDisplayName)
{
var countryNames = new List<SelectListItem>();
foreach (var cul in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
var country = new RegionInfo(new CultureInfo(cul.Name, false).LCID);
var item = new SelectListItem()
{
Text = country.DisplayName,
Value = country.DisplayName
};
if (!String.IsNullOrEmpty(selectedDisplayName) && country.DisplayName.Equals(selectedDisplayName))
{
item.Selected = true;
}
countryNames.Add(item);
}
IEnumerable<SelectListItem> nameAdded = countryNames.GroupBy(x => x.Text).Select(x => x.FirstOrDefault()).ToList().OrderBy(x => x.Text);
return nameAdded;
}
My web.config has this (with no effect):
<system.web>
<globalization uiCulture="da-DK" culture="da-DK" />
</system.web>
Anyone got any suggestions?