The problem is, when click on submit button I always receive null in controller action method. Any help will be appreciated. Thanks in advance This is my view
<div class="box-body">
<table class="">
<thead>
<tr>
<th>
<label>Employee Name</label>
</th>
<th>
<label>Remarks</label>
</th>
<th>
<label>Absent</label>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.employeeAttendance)
{
<tr>
<td>
@Html.HiddenFor(modelitem => item.EId)
@Html.HiddenFor(modelitem => item.Date)
@Html.DisplayFor(modelitem => item.EName)
</td>
<td>
@Html.EditorFor(modelitem => item.Remarks, new { @class = "form-control" })
</td>
<td>
@Html.EditorFor(modelitem => item.Status, new { @class = "form-control" })
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<input type="submit" value="Create" class="btn btn-primary" /> |
@Html.ActionLink("Back to List", "Index")
</div>
</div>
This is my controller action method
public async Task<ActionResult> Create(EmployeeAttendance empAttendance)
{
if (ModelState.IsValid)
{
//Logic here
}
return View(empAttendance);
}
This is my ViewModel
public class EmpAttendanceViewModel
{
public bool Status { get; set; }
public string Remarks { get; set; }
public DateTime Date { get; set; }
public int EId { get; set; }
public string EName { get; set; }
}
And this is my Custom View
public class EmployeeAttendance
{
public IEnumerable<EmpAttendanceViewModel> employeeAttendance { get; set; }
}
The problem is, when click on submit button I always receive null in controller action method. Any help will be appreciated. Thanks in advance