0

I have a simple table

@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>
}

The save action

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

How can I get MVC to deserialize the post back to my model?

4

1 回答 1

0

对于集合,您需要做一个编辑器模板并使用

@Html.EditorFor(m => m.Collection);
于 2011-10-07T09:17:32.250 回答