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; }
Changed my view from checkbox to radiobutton:
YES
@Html.RadioButtonFor(modelItem => modelItem.questionnaires[itemindex].Answer,true, new { id = "rbYes"})
NO
@Html.RadioButtonFor(modelItem => modelItem.questionnaires[itemindex].Answer,false, new { id = "rbNo"})
Not Applicable
@Html.RadioButtonFor(modelItem => modelItem.questionnaires[itemindex].Answer,null, new { id = "rbNotApp"})
my problem now is how to pass a null value when not applicable?