I am outputting data that I get from a query and placing an input box by each one on the view.
This is a partial view inside one of my forms.
@model IEnumerable<Project.Models.VehicleTypeSeat>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
int counter = 0;
}
<p>
</p>
<table>
<tr>
<th>
<div class="editor-field">
Crew
</div>
</th>
<th>
Description
</th>
</tr>
@{
@for (var item in model)
{
<tr>
<input type="hidden" name="raceSeats.index" value="@(counter)" />
<td>
@Html.DropDownList(item.CrewID, null, "--Select Crew Member--", htmlAttributes: new { @class = "form-control", @name = "raceSeats["+@counter+"].PersonID" })
</td>
<td>
@Html.DisplayFor(modelItem => item.VehicleTypeSeatDescription)
</td>
</tr>
counter += 1;
}
</table>
}
I am trying to accomplish this kind of thing to read as an array by the post:
<input type="hidden" name="people.index" value="0" />
<input type="text" name="people[0].firstname" />
<input type="text" name="people[0].lastname" />
The problem is that I am having trouble manipulating the names of "DisplayFor"
and "DropDownList"