i have a class
public class CustomBenefitCommittee
{
public int PlanOptionId { get; set; }
public bool IsChecked { get; set; }
public string PlanOptionName { get; set; }
}
and i have took this class as a list type of model in my razer view
@model List<MIHR.Business.CustomClasses.CustomBenefitCommittee>
@{
int Counter = 0;
}
<table class="table table-bordered" id="tblPlanLst">
<thead>
<tr>
<th>
select
</th>
<th>
Benefit Option
</th>
</tr>
</thead>
<tbody>
@foreach (var Enrol in Model)
{
<tr>
<td> <input type="checkbox" name="customBenefitCommittee[@Counter].IsChecked" class="clsCheck" /></td>
<td>
@Enrol.PlanOptionName
</td>
</tr>
Counter++;
}
</tbody>
</table>
<input type="submit" id="btnSubmitSave" value="Save" name="buttonType" class="btn btn btn-primary">
now when i post this form to controller with checking the checkbox i get always false in this checkbox IsChecked property. can anyone help me out with it.
value. Generate your html correctly using@for(int i = 0; i < Model.Count; i++) { @Html.CheckBoxFor(m => m[i].IsChecked) }- refer also Post an HTML Table to ADO.NET DataTable