문제

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?

도움이 되었습니까?

해결책

For collections you need to do a Editor template and use

@Html.EditorFor(m => m.Collection);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top