2014-05-24 76 views
0
@Html.DropDownListFor(m => m.Baled, new SelectList(new [] {"Select Type","Option1", "Option2", "Option3"})) 

我想在下拉列表中添加一個css類。在下拉列表中添加課程

我已經試過這

@Html.DropDownListFor(m => m.Baled, new SelectList(new [] {"Select Type","Option1", "Option2", "Option3"}, new {@class="myclass"})) 

但它不工作

如果任何人都可以建議我任何其他更好的方式來顯示下拉列表將也沒關係。

回答

2

您有錯誤的地方關閉括號。您已在第二個參數列表中定義屬性。實際上應該先關閉並在最後一個參數中定義Html.DropDownListFor

@Html.DropDownListFor(m => m.Baled, new SelectList(new[] { "Select Type", "Option1", "Option2", "Option3" }), new { @class = "myclass" })