My field is as follows in my class:
public bool? meuCampo { get; set; }
And in my view it looks like this:
@Html.CheckBoxFor(m => m.meuCampo)
But this way it is not allowed, because I can not explicitly convert type bool?
to bool
, so to try to solve this I did it in the form below, using cast
:
@Html.CheckBoxFor(m => (bool)m.meuCampo)
To do this, so also occurs an error that is as follows:
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
So according to the facts, would you have any other way to create a checkbox, using Helper
Html
, with properties of type Nullable<bool>
?