With a view model containing the field:
public bool? IsDefault { get; set; }
I get an error when trying to map in the view:
<%= Html.CheckBoxFor(model => model.IsDefault) %>
Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)
I've tried casting, and using .Value
and neither worked.
Note the behaviour I would like is that submitting the form should set IsDefault
in the model to true or false. A value of null
simply means that the model has not been populated.