I am trying to pass all data from an array inside my view back to a controller. I'm not sure how to do this using my ViewModel.
Model Class
public class ResultsViewModel
{
public int?[] ProgramIds { get; set; }
}
Form inside of the View
@using (Html.BeginForm("ExportCsv", "SurveyResponse", FormMethod.Post))
{
// Should I be looping through all values in the array here?
@Html.HiddenFor(x => x.ProgramIds)
<input type="submit" value="Submit" />
}
Controller I am posting to
[HttpPost]
public ActionResult ExportCsv(ResultsViewModel ResultsViewModel)
{
}