I am developing MVC4 application. I am having troubles in getting checked value in checkbox. I am using MVC4 razor. I am receiving null in the controller action method. This is my Index.cshtml code.
@for (int i = 0; i < Model.EmploymentType.Count; i++)
{
@Html.CheckBoxFor(m => m.EmploymentType[i].isChecked, new { id = "employmentType_" + i })
@Html.HiddenFor(m => m.EmploymentType[i].checkBoxName)
@Html.DisplayFor(m => m.EmploymentType[i].checkBoxName)
}
this is my actionmethod.
[httpget]
public ActionResult Index(int? clientId,DateTime?,bool? employmentType_0)
{
}
In the above action method I am receiving null value for employmentType_0 This is my class
public class logDetailsEnumeration
{
public List<checkboxClass> EmploymentType { get; set; }
}
public class checkboxClass
{
public int checboxID { get; set; }
public string checkBoxName { get; set; }
public bool isChecked { get; set; }
}
I have initialised with checkboxes in controller as follows.
EmploymentType = new List<checkboxClass>
{
new checkboxClass { checkBoxName = "ChangedValues" }
}
May I know Why I am getting null values on back in controller on form submit? Thank you.
Aucun commentaire:
Enregistrer un commentaire