Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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
Asp.net MVVM模式MVC应用程序中的复选框绑定_Asp.net_Asp.net Mvc_Model View Controller_Mvvm_Data Binding - Fatal编程技术网

Asp.net MVVM模式MVC应用程序中的复选框绑定

Asp.net MVVM模式MVC应用程序中的复选框绑定,asp.net,asp.net-mvc,model-view-controller,mvvm,data-binding,Asp.net,Asp.net Mvc,Model View Controller,Mvvm,Data Binding,我试图根据数据库中存储的组的数量填充MVC视图上的复选框列表 复选框项的模型: 公共类CheckListItem { 页面的ViewModel包含上述内容的列表 公共列表MeGroupList{get;set;} 他认为: @for (var i = 0; i < MeGroupList.Groups.Count(); i++) {

我试图根据数据库中存储的组的数量填充MVC视图上的复选框列表

复选框项的模型:

公共类CheckListItem {

页面的ViewModel包含上述内容的列表

公共列表MeGroupList{get;set;}

他认为:

                   @for (var i = 0; i < MeGroupList.Groups.Count(); i++)
                    {
                        
                        @Html.HiddenFor(x => x.MeGroupList[i].Value)
                        @Html.HiddenFor(x => x.MeGroupList[i].Text)
                        @Html.CheckBoxFor(x => x.MeGroupList[i].Selected, new { @class = "form-check-input" })
                        <label class="form-check-label" style="margin-right: 10px">
                            <font color="black"><b> @Model.MeGroupList[i].Text</b></font>
                        </label>
                    }
for(var i=0;ix.MeGroupList[i].Value) @Html.HiddenFor(x=>x.MeGroupList[i].Text) @Html.CheckBoxFor(x=>x.MeGroupList[i]。选中,新建{@class=“表单检查输入”}) @Model.MeGroupList[i].Text } 最后,呈现的HTML:

<input id="MeGroupList_0__Text" name="MeGroupList[0].Text" type="hidden" value="BIW">
<input class="form-check-input" data-val="true" data-val-required="The Selected field is required." id="MeGroupList_0__Selected" name="MeGroupList[0].Selected" type="checkbox" value="true">
<input name="MeGroupList[0].Selected" type="hidden" value="false">
<label class="form-check-label" style="margin-right: 10px">
                                <font color="black"><b> BIW</b></font>
                            </label>

白车身
当我提交表单并检查模型时,MeGroupList计数为零。没有任何内容被绑定回post。我花了一天时间尝试了多种方法,但运气不佳。我无法将其绑定到post上。我在网上的各种文章中找到了上述内容,并且就我所知,这些内容与所显示的示例完全相同。如有任何帮助,将不胜感激d

<input id="MeGroupList_0__Text" name="MeGroupList[0].Text" type="hidden" value="BIW">
<input class="form-check-input" data-val="true" data-val-required="The Selected field is required." id="MeGroupList_0__Selected" name="MeGroupList[0].Selected" type="checkbox" value="true">
<input name="MeGroupList[0].Selected" type="hidden" value="false">
<label class="form-check-label" style="margin-right: 10px">
                                <font color="black"><b> BIW</b></font>
                            </label>