So my problem right now is that I cant get my model into my controller when I submit this following form. I am trying to have the items from the BillingCodes (which is a lis
You are doing a foreach on the views, so the input elements should have the values posted somewhere like to this :
name="BillingCodes[0].EnterTimeHours"
, name="BillingCodes[0].EnterTimeMinutes"
you can inspect in the network tab the request on Chrome Developer Tools (CTRL+SHIFT+C)
or just viewing the source. If this is the case, you are submitting multiple BillingCodeObj objects. You must have a controller that receive that.
Take a look at the source code as this can greatly help you understand what's going on behind the scenes.
Try this on your controller:
[HttpPost]
public void SubmitTimesheet(IEnumerable billingCodes){
}
You can also (for debugging purposes) do
public void SubmitTimesheet(FormCollection form){}
and inspect the form how is populated on debug.
after comments and more code provided change your view to :
@using (Html.BeginForm("SubmitTimesheet", "Timesheet", FormMethod.Post))
{
@Html.EditorFor(m=>m.BillingCodes)
}
create a new cshtml in EditorTemplates/BillingCodeObj.cshtml :
@model BillingCodeObj