在MVC下拉菜单中选择的选择值

时间:2018-10-11 10:32:48

标签: asp.net-mvc jquery-select2 multi-select

  

我需要一种在多选下拉菜单中设置已经选择的值的方法   在Web应用程序(ASP.NET,Mvc 5)的编辑视图中:

 <div class="form-group">
   <div class="col-md-10">
        @Html.DropDownList("EntityId", selectList: (IEnumerable<SelectListItem>)ViewBag.EntityId, htmlAttributes: new { @class = "form-control select2", multiple = "multiple" })
   </div>
</div>

//控制器

  ViewBag.EntityId = new SelectList(context.CompanyEntity.Where(x => x.UserProfile.Any(u => u.UserProfileId == id)), "EntityId", "EntityName"); 
  

我需要通过选择已选择的值来进行编辑。

0 个答案:

没有答案
相关问题