I have a view in which I have rendered partial view in a loop. There is a list and partial view have is binded with each item in a list. I am not getting the value of the list on controller after value is entered.
Here is my view:
<table id="resourceRequirement" class="table" width="100%" border="0">
<thead>
<tr style="background-color:#dfdfdf;">
<td><div align="center">PRIORITY</div></td>
<td><div align="center">SYSTEM RESOURCE / COMPONENT</div></td>
<td><div align="center">RECOVERY TIME OBJECTIVE</div></td>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ResourceRequirement)
{
@Html.Partial("~/Views/Shared/_ResourceRequirement.cshtml", item)
}
</tbody>
</table>
Here is my partial view:
@model DisasterManagementSystem.Models.BusinessImpactAnalysis.ResourceRequirement
<tr>
<td>
@Html.TextBoxFor(m => m.priority)<br />
<div style="color:red;">
@Html.ValidationMessageFor(model => model.priority)
</div>
</td>
<td>
@Html.TextBoxFor(m => m.systemresource)<br />
<div style="color:red;">
@Html.ValidationMessageFor(model => model.systemresource)
</div>
</td>
<td>
@Html.TextBoxFor(m => m.receveryTime)<br />
<div style="color:red;">
@Html.ValidationMessageFor(model => model.receveryTime)
</div>
</td>
</tr>
Here is my list:
public List<ResourceRequirement> ResourceRequirement { get; set; }
And the class is here:
public class ResourceRequirement
{
[Required(ErrorMessage = "*")]
public string priority { get; set; }
[Required(ErrorMessage = "*")]
public string systemresource { get; set; }
[Required(ErrorMessage = "*")]
public string receveryTime { get; set; }
}
Please advise when i am trying to get the list from model on post I am getting the list as null.