gpt4 book ai didi

asp.net-mvc - ASP.NET MVC 加拿大省下拉列表

转载 作者:行者123 更新时间:2023-12-04 08:30:30 25 4
gpt4 key购买 nike

有人有带有加拿大省份列表的下拉列表辅助方法吗?

基于此question我一直在寻找加拿大省的等效的。希望这会节省一些额外的输入,或者导致更好的答案。

最佳答案

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"); }
}

}

然后按以下方式使用:

<%= Html.DropDownList("province", CanadianProvinces.ProvinceSelectList)%>

关于asp.net-mvc - ASP.NET MVC 加拿大省下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1375941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com