4
My field is as follows in my class:
public bool? meuCampo { get; set; }
And in my view it’s like this:
@Html.CheckBoxFor(m => m.meuCampo)
Only that way it’s not allowed, because I can’t explicitly convert the type bool?
for bool
, so to try to solve this I did the way below, using cast
:
@Html.CheckBoxFor(m => (bool)m.meuCampo)
Then there is also an error which 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, there would be some other way to create checkboxes, using the Helper
Html
, with properties of the type Nullable<bool>
?