I want to display 2 fields one is checkbox and the another one is description in the case of the checkbox for some reason always is coming FALSE using CheckBoxFor the description is coming fine!
HTML Code
<table>
@for (var i = 0; i < Model.PurchaseOrder.LineItems.Count(); i++)
{
<tr>
<td>
@Html.CheckBoxFor(m => m.LineItems[i].Received)
</td>
<td>
@Model.PurchaseOrder.LineItems.ToArray()[i].Description
</td>
</tr>
}
</table>
Model
public class LineItem
{
[MaxLength(2000)]
public string Description { get; set; }
public bool Received { get; set; }
}
Model
public class PurchaseOrder
{
[MaxLength(100)]
public string AccountNumber { get; set; }
public IEnumerable<LineItem> LineItems { get; set; } = new List<LineItem>();
}
ViewModel
public class ViewModel
{
public PurchaseOrder PurchaseOrder { get; set; }
public List<LineItem> LineItems { get; set; }
}
I need to know how could be the reason that is coming FALSE the CheckBoxFor Thanks!