jeudi 21 janvier 2016

populate boolean values in checkbox in mvc

I have following fields Db table , I want populate those values in check boxes

    public Nullable<bool> Report_Users { get; set; }
    public Nullable<bool> Innovation_Discussion_User { get; set; }

this is specific row in above table

enter image description here

I'm expecting ,

  1. empty check box if Values are NULL or FALSE
  2. checked check box if values are TRUE

this is the syntax I've been used ,

            @Html.CheckBox("Report User", Model == null ? false : (Model.Report_Users == Model.Report_Users ? true : false), new { @value = "false"  }) Report User
             &nbsp; 
            @Html.CheckBox("Innovation Discussion User", Model == null ? false : (Model.Innovation_Discussion_User == Model.Innovation_Discussion_User ? true : false), new { @value = "false"  }) Innovation Discussion User

but this seems not poplate correct values,

both check boxes showing checked always

enter image description here




Aucun commentaire:

Enregistrer un commentaire