繁体   English   中英

ASP.NET MVC Multiselect ListBox没有选择多个值

[英]ASP.NET MVC Multiselect ListBox is not selecting multiple values

这是我的模特班

public class OperationStudyInputViewModel
{
   public IEnumerable<string> AttachmentId { get; set; }
}

这是我的控制器方法:

public ActionResult OperationStudyInput()
{
    var attachmentList = _dbContext.AttachmentAndFolders
        .Where(x => x.IsAttachementOrFolder == "Attachment")
        .Select(x => new 
        {
            x.AttchmentFolderId,
            x.Name
        }).ToList();
    ViewBag.AttachmentList = new MultiSelectList(attachmentList, "AttchmentFolderId", "Name");
}

这是View:

<div class="input-group input-group-lg col-md-6">
    @Html.LabelFor(model => model.AttachmentId, htmlAttributes: new { @class = "input-group-addon" })
    @Html.ListBoxFor(model => model.AttachmentId,(MultiSelectList)ViewBag.AttachmentList)
</div>

MultiSelet文本框可以正确呈现,但是它只选择一个值,而不选择多个值。

无法确定问题出在哪里! 任何帮助请!

多选列表框要求您按住Ctrl才能选择多个项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM