I am trying to create a CheckBox in MVC using Razor and here is the Below code for it :

@Html.CheckBoxFor(m => m.PDModel.EducationMasterList[0].eduMarksheet, new { @class = "marksheet" })

But it is showing error Cannot implicitly convert 'bool?' to 'bool'. Are you missing the type cast. To Solve this i have used @Html.CheckBoxFor(m => m.PDModel.EducationMasterList[0].eduMarksheet.Value, new { @class = "marksheet" }) and it is giving this error : Nullable object must have a value.

and @Html.CheckBoxFor(m => m.PDModel.EducationMasterList[0].eduMarksheet.GetValueOrDefault(), new { @class = "marksheet" }) and it is giving this error : Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

Any Suggestion will be thankful.

Thanks in Adavance

Related posts

Recent Viewed