【发布时间】:2014-02-24 08:01:01
【问题描述】:
我创建了一个字典并用枚举值设置它。我想使用 Html.DropdownlistFor 填充下拉列表。这是我的行动:
public ActionResult Index()
{
Dictionary<string, string> TagsDictionary = new Dictionary<string, string>();
Enum.GetNames(typeof(System.Tags)).ToList().ForEach(x => TagsDictionary.Add(x, Resources.PageResources.ResourceManager.GetString(String.Format("Tags_{0}", x))));
return View(TagsDictionary);
}
但我不知道如何编写 View 以在页面加载时获取下拉列表中的字典值
【问题讨论】:
-
为什么要创建一个字典来填充视图中的下拉菜单?
标签: asp.net-mvc asp.net-mvc-4 razor html-helper