是否可以在页面加载或发布到服务器时预选项目。
这就是我现在所拥有的......
<%=Html.DropDownList("dllMonths",
new SelectList(new List<string>() {
"", "January", "Feburary", "March", "April", "June",
"July", "August", "September", "October", "November",
"December"}),
new { onchange="this.form.submit();" })%>
答案 0 :(得分:12)
设置SelectList的SelectedValue属性,或将其作为第二个参数传递给SelectList构造函数。
<% = Html.DropDownList ( "dllMonths",
new SelectList ( new List ( )
{ "", "January", "Feburary", "March",
"April", "June", "July", "August",
"September", "October", "November",
"December" },
"April" ),
new { onchange = "this.form.submit();" }
)%>