Hi i have a check box for a checklist program that i am making, its type is bool? so that i can pass a null value if the answer is not applicable (they should leave the yes and no blank), otherwise they should tick yes or no..my problem now is how can i save the answer to my answer property.

View:

   YES
              @Html.CheckBox("chkYes", Model.questionnaires[itemindex].Answer.HasValue  ? bool.Parse(Model.questionnaires[itemindex].Answer.ToString()):false)
   NO
               @Html.CheckBox("chkNo", Model.questionnaires[itemindex].Answer.HasValue ? !bool.Parse(Model.questionnaires[itemindex].Answer.ToString())  : false)

Model:

public bool? Answer { get; set; }

Related posts

Recent Viewed