In 2sxc App, in my content type, I have a dropdown list of Canadian provinces that have a name and a value for the abbreviation. It looks like this:
British Columbia:bc Alberta:ab Prince Edward Island:pei
Etc.
I want to be able to use both the text labels and the select value in my c# razor template. When I use @Content.Province, it only outputs the value so if I select British Columbia it outputs it as "bc". How can I output the label of the selection so that it outputs "British Columbia"?
I ended up using this approach:
@{
var provinceMappings = new Dictionary<string, string>();
provinceMappings.Add("ab", "Alberta");
provinceMappings.Add("bc", "British Columbia");
provinceMappings.Add("mb", "Manitoba");
provinceMappings.Add("nb", "New Brunswick");
provinceMappings.Add("nl", "Newfoundland & Labrador");
provinceMappings.Add("nwt", "Northwest Territories");
provinceMappings.Add("ns", "Nova Scotia");
provinceMappings.Add("nu", "Nunavut");
provinceMappings.Add("on", "Ontario");
provinceMappings.Add("pei", "Prince Edward Island");
provinceMappings.Add("qc", "Quebec");
provinceMappings.Add("sk", "Saskwatchewan");
provinceMappings.Add("yt", "Yukon Territories");
}
@provinceMappings[p]