Please i have a model class below
public class EditJob
{
public JobPost JobPost { get; set; }
public IEnumerable<JobRequirement> JobRequirement { get; set; }
public IEnumerable<JobResponsibility> JobResponsibility { get; set; }
}
I strongly bind the class to a view and want to use it for editing in controller. I have a controller which receives model like below.
[HttpPost]
public ViewResult SaveJob(EditJob model)
{
}
I Dynamically bind my Ienumerable to texboxes in my view like below.
@for (int i = 0; i < Model.JobResponsibility.Count();i++ )
{
JobWebsite.Domain.Enitities.JobResponsibility rs = Model.JobResponsibility.ElementAt(i);
<label class="control-label">Responsibility :</label>
Html.Hidden("Responsibility[" + i + "]", rs);
@Html.TextBoxFor(x => rs, new { @class = "form-control" }) <br />
}
On my button click, I realized the two IEnumerable methods from my model are not binding . The JobPosts in the model is not empty, yet my Ienumerable properties not always empty . I added a hidden field holding my values but i am having problem passing them to the controller. Please how do i achieve this ?