【发布时间】:2018-01-16 12:24:27
【问题描述】:
我使用下面的代码进行下拉
@if (ViewBag.EventContentTypeId == Convert.ToInt32(EventContentType.Events))
{
<div class="col-sm-3 form-group input" style="padding-left:0">
<div class="input-group">
@Html.DropDownList("EventCategoryDDL", @ViewBag.EventCategories as IEnumerable<SelectListItem>, "-- Select Category --", new { @class = "form-control" })
<span class="input-group-addon">
<i class="fa fa-file-text" aria-hidden="true"></i>
</span>
</div>
</div>
}
我想用复选框将这些更改为多选下拉菜单。
这是我的控制器代码,它在选择列表中,我无法修改为多选列表有没有办法更改为选择列表的多选列表。
ViewBag.EventCategories = ViewBag.EventContentTypeName == EventContentTypeString.Events.Value ? _commonService.GetEventCategoriesModel().Where(category =>category.OptionText != "Camp Kaufmann").Select(i => new SelectListItem()
{
Text = i.OptionText,
Value = i.OptionValue.ToString()
})
_commonService.GetEventCategoriesModel().Select(i => new SelectListItem()
{
Text = i.OptionText,
Value = i.OptionValue.ToString()
});
我应该如何在控制器端更改为多选列表,以及如何将下拉菜单与多选复选框绑定。
【问题讨论】:
标签: javascript c# asp.net-mvc