【发布时间】:2014-06-23 01:03:39
【问题描述】:
我的模型类中有以下代码:-
public class PageOptions
{
public PageOptions()
{
int size = Int32.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["TechPageSize"]);
NameSelectionOptions = new SelectList(
new List<SelectListItem> {
new SelectListItem { Text=size.ToString(), Value = size.ToString()},
new SelectListItem { Text="50", Value = "50"},
new SelectListItem { Text="100", Value = "100"},
new SelectListItem { Text="200", Value = "200"},
new SelectListItem { Text="500", Value = "500"}
}, "Value", "Text");
}
public SelectList NameSelectionOptions { get; set; }
}
}
但是我如何在 Html.DropDownList 中显示 SelectList ?并将默认值设置为大小? 谢谢
【问题讨论】:
-
3年后,您对答案满意了吗? :)
-
即将进入第五个年头......你还开心吗? :)
标签: asp.net-mvc-4 razor html-helper