【问题标题】:Post mvc3 table to controller action将 mvc3 表发布到控制器操作
【发布时间】:2011-10-06 11:24:41
【问题描述】:

我有一张简单的桌子

@using (Html.BeginForm("Save", "Subscription", FormMethod.Post))
{
    <table>
        <tr>
            <th>
                Name
            </th>
            <th>
                Report
            </th>            
        </tr>

        @foreach (var item in Model.ReportSubscriptions)
        {
            <tr>
                <td>
                    @Html.HiddenFor(item.Id)
                    @Html.TextBoxFor(item.Name)                    
                </td>
                <td>
                    @Html.TextBoxFor(item.Report)
                </td>
            </tr>
        }
    </table>
    <button type="submit">Save</button>
}

保存动作

public ViewResult Save(IEnumerable<ReportSubscription> list)
{
    throw new NotImplementedException();
}
}

如何让 MVC 将帖子反序列化回我的模型?

【问题讨论】:

    标签: asp.net-mvc-3 html-table controller-action


    【解决方案1】:

    对于收藏,你需要做一个编辑器模板并使用

    @Html.EditorFor(m => m.Collection);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-10
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 2011-08-06
      • 1970-01-01
      相关资源
      最近更新 更多