4

有没有办法在页面加载或发布到服务器时预先选择一个项目..

这就是我现在所拥有的..

<%=Html.DropDownList("dllMonths", 
    new SelectList(new List<string>() {
       "", "January", "Feburary", "March", "April", "June", 
       "July", "August", "September", "October", "November", 
       "December"}), 
    new { onchange="this.form.submit();" })%>
4

1 回答 1

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();" } 
                       )%>
于 2009-01-16T15:22:49.140 回答