Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET MVC Multiselect列表框未选择多个值_C#_Asp.net_Asp.net Mvc_Razor - Fatal编程技术网

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>