I am trying to return the results of a table back to the controller for further manipulation. Once returned to the controller the value shows as null. In the past I have b
You cannot use ElementAt()
in a HtmlHelper
method that generates form controls (look at the name
attribute your generating - it does not match your model).
Either change the model to be IList<T>
@model List<Project.Models.Item>
and use a for
loop
@for (int i = 0; i < Model.Count; i++)
{
....
@Html.HiddenFor(m => m.[i].Name)
....
or change use a custom EditorTemplate
for typeof Item
, and in the main view, use @Html.EditorFor(m => m)
to generate the correct html for each item in the collection.