@{
IDictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("class", "selectpicker");
dic.Add("data-style", "btn-co2;");
}
@Html.DropDownList("drpdept", (SelectList)ViewData["deptList"], "--Select One--", dic)
这个是直接在页面当中编写,@{} 代表中的代码相当于在后台代码写法