日期:2014-05-16  浏览次数:20505 次

MVCs中怎么给子model赋值
比如页面Model为 school

  <div >
 学校名称:
   </div>
<div>
 <%: Html.TextBoxFor(m => m.Name)%>
  <table>
    <% foreach (var item in Model.listClass)
    { %>
     <tr>
         <td>班级名称</td>
        <td>
        <%: item.ItemType %>
        <%: Html.TextBoxFor(m => item.Name)%>
         这里该如何写?
         </td>
     </tr>
<% } %>
</table>
 </div>


我想在我的控制器中自动得到Model.listClass的值


 public ActionResult  Create(school model)
    {
             List<Class> list=model.listClass;
             //在此得到视图中每个输入的班级名称
    }
------解决方案--------------------
参考:
http://www.progware.org/Blog/post/ASPNET-MVC-Binding-to-Listse28093Enumerables-on-POST-with-JQuery.aspx

完整的代码:
http://www.progware.org/Blog/file.axd?file=ASPNETMVC.MapEnumerables.rar