I know this question has been asked about 100 times, I've gone through them, i cant see anything that i might be doing wrong. Any help would be appreciated
When posting back the ImportModel list is empty.
@model Models.ImportModel
<div class="main-content">
<div class="container">
<h1>Uploaded Cars</h1>
@using (Html.BeginForm("Confirm", "Import", FormMethod.Post, new { @class = "form-horizontal" }))
{
<table id="importVehiclesTable" class="table">
<thead>
<tr>
<th>Registration</th>
<th>Details</th>
<th></th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.Vehicles.Count; i++)
{
<tr>
<td>@Html.DisplayFor(m => m.Vehicles[i].RegistrationNumber)</td>
<td>@Html.DisplayFor(m => m.Vehicles[i].Name)</td>
<td></td>
</tr>
}
</tbody>
</table>
<br />
<br />
<input type="submit" value="Import Vehicles" class="btn btn-primary" />
<input type="reset" value="Back" class="btn" onclick="history.back();" />
}
</div>
My Model,
/// <summary>
///
/// </summary>
public class ImportModel : BaseModel
{
/// <summary>
/// Gets or sets the cars.
/// </summary>
/// <value>
/// The cars.
/// </value>
public List<VehicleAddViewModel> Vehicles { get; set; }
}
my action, but the Vehicles obj is null.
[HttpPost]
public ActionResult Confirm(ImportModel importModel)
{
//Will be saving to the DB here
return null;
}