I have a view model which is just
public class Visits
{
public List<Visit> visits { get; set; }
}
In my visit model I have a
public bool ValidVisit { get; set; }
I am able to pass everything to my view ok and render all of the visits on the view. The view looks like
@model TheWallSite.ObjectModels.Visits
@{
ViewBag.Title = "Potential invalid visits!";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
<fieldset>
<table>
<tr><th>Check In/Out Time</th><th>Visit Type</th><th>In/Out</th><th>IP</th><th>SSO ID</th><th>Valid Visit</th></tr>
@foreach (var item in Model.visits)
{
<tr>
<td>@Html.DisplayFor(model => item.InOutTime)</td>
<td>@Html.DisplayFor(model => item.VisitType)</td>
<td>@Html.DisplayFor(model => item.VisitName)</td>
<td>@Html.DisplayFor(model => item.IP)</td>
<td>@Html.DisplayFor(model => item.SSO)</td>
<td>@Html.EditorFor(model => item.ValidVisit)</td>
</tr>
}
</table>
<input type="submit" value="Submit" />
</fieldset>
}
The problem I am having is I want the end user to be able to check/uncheck the ValidVisit and then pass these back to the controller and make the correct changes in my database.. I am having a heck of a time figuring out how to do this. Any suggestions? My [HttpPost] controller signature is
public ActionResult ListQuestionableVisits(Visits model, FormCollection forms)
but nothing seems to be getting back to the controller.
ListQuestionableVisitsis invoked? Because you should set this as the target action in yourHtml.BeginForm()@Html.BeginForm()posts back to the same action, so you don't need any parameters in this case.