更新时间:2022-11-03 08:01:07
问题是你没有指定你的表单提交的对象是类型CustomerModuleList的。
The problem is you're not specifying that the object your form is submitting is of type CustomerModuleList.
在你的意见/共享/ EditorTemplates文件中创建一个名为CustomerModuleList.cshtml和CustomerModules.cshtml意见。
In your views/Shared/EditorTemplates file create views named CustomerModuleList.cshtml and CustomerModules.cshtml.
在CustomerModuleList.cshtml把
In CustomerModuleList.cshtml put
@model CustomerModuleList
<% foreach (var module in Model.Modules){%>
Html.EditorFor(x => module);
<% } %>
,然后在CustomerModules.cshtml粘
and then in CustomerModules.cshtml stick
@model CustomerModules
<tr>
<td><%:Html.Label(Model.ModuleName) %></td>
<td>
<%:Html.CheckBoxFor(x=>x.IsActive) %>
</td>
<td><%:Html.Label(Model.ActiveDate.ToString()) %></td>
</tr>
然后在您的视图代码片段,其中
then in your view snippet replace the for loop with
Html.EditorFor(x => Model)
用不同的IEnumerable型我做了测试这和它的工作。
tested this with a different IEnumerable of a type I made and it worked.