Anyone have have a dropdownlist helper method with a list of Canadian Provinces?
Based upon this question I was looking to find a Canadian Province equivalent. Hopefully this will save someone some extra typing, or lead to an even better answer.
Anyone have have a dropdownlist helper method with a list of Canadian Provinces?
Based upon this question I was looking to find a Canadian Province equivalent. Hopefully this will save someone some extra typing, or lead to an even better answer.
public class CanadianProvinces
{
public static readonly IDictionary<string, string> ProvinceDictionary = new Dictionary<string, string>
{
{"ALBERTA", "AB"},
{"BRITISH COLUMBIA", "BC"},
{"MANITOBA", "MB"},
{"NEW BRUNSWICK", "NB"},
{"NEWFOUNDLAND AND LABRADOR", "NL"},
{"NORTHWEST TERRITORIES", "NT"},
{"NOVA SCOTIA", "NS"},
{"NUNAVUT", "NU"},
{"ONTARIO", "ON"},
{"PRINCE EDWARD ISLAND", "PE"},
{"QUEBEC", "QC"},
{"SASKATCHEWAN", "SK"},
{"YUKON", "YT"},
};
public static SelectList ProvinceSelectList
{
get { return new SelectList(ProvinceDictionary, "Value", "Key"); }
}
}
And then it is used in the following manner:
<%= Html.DropDownList("province", CanadianProvinces.ProvinceSelectList)%>