C# ASP.NET MVC Multiselect列表框未选择多个值
这是我的模型课C# ASP.NET MVC Multiselect列表框未选择多个值,c#,asp.net,asp.net-mvc,razor,C#,Asp.net,Asp.net Mvc,Razor,这是我的模型课 public class OperationStudyInputViewModel { public IEnumerable<string> AttachmentId { get; set; } } 以下是我的看法: <div class="input-group input-group-lg col-md-6"> @Html.LabelFor(model => model.AttachmentId, htmlAttributes:
public class OperationStudyInputViewModel
{
public IEnumerable<string> AttachmentId { get; set; }
}
以下是我的看法:
<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>
@LabelFor(model=>model.AttachmentId,htmlAttributes:new{@class=“input group addon”})
@Html.ListBoxFor(model=>model.AttachmentId,(MultiSelectList)ViewBag.AttachmentList)
MultiSelet Textbox正在正确渲染,但它只选择了一个值,而没有选择多个值
无法确定问题的实际位置!!请帮忙多选列表框要求您按住Ctrl键选择多个项目。仅选择值是什么意思?它仅选择一个值。如果在选择一个值后尝试选择另一个值,则上一个选择将丢失。不相关,但是建议您只使用
ViewBag.AttachmentList=dbContext.AttachmentAndFolders.Where(…).Select(x=>newselectListItem{Value=x.AttchmentFolderId,Text=x.Name})
和@Html.ListBoxFor(m=>m.AttachmentId,(IEnumerable)ViewBag.AttachmentList)
您的声明不可能实现-您的代码生成一个
元素。您是否有任何javascript正在改变行为?可能没有!!顺便问一下,我应该按住控制按钮选择多个,还是只是连续单击单个。。。??
<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>