controller
atmcusomers是dbcontext对应的表
ViewBag.CustomerType = new MultiSelectList(db.AtmCustomers.Where(a => a.Deleted == false).OrderBy(a => a.Name).ToList(), "Id", "Name", null);
ViewBag.ATMModelType = new MultiSelectList(db.SysProjects.Where(a => a.Deleted == false).OrderBy(a => a.Name).ToList(), "Id", "Name", null);
// , null);
view
@Html.DropDownList("CustomerType", (MultiSelectList)ViewBag.CustomerType, new { @class = "chosen-select", multiple = "multiple", style = "width:370px;height:33px;" })
<th>Branch Type</th>
<td colspan="2">
<div class="col-xs-4">
@Html.DropDownList("ATMModelType", (MultiSelectList)ViewBag.ATMModelType, new { @class = "chosen-select", multiple = "multiple", style = "width:370px;height:33px;" })
</div>
</td>
设置默认值
<script>
$(function () {
//debugger
$("#CustomerType").attr("data-placeholder", "ALL");
$("#ATMModelType").attr("data-placeholder", "ALL");
})
</script>