Html.CheckBoxFor get Func from inputs . You should try this :
@Html.CheckBoxFor(m=> m.HasImage)
Html.CheckBoxFor get Func from inputs . You should try this :
@Html.CheckBoxFor(m=> m.HasImage)
You can use below syntax to select/un-select check box based on the value
if HasImage is nullable then below format
@Html.CheckBox("HasImage", (item.HasImage?? false) ? item.HasImage: false)
if HasImage is not nullable then simply keep the value
@Html.CheckBox("HasImage", item.HasImage)
I’m simply trying to get a checkbox to display checked if a property (bool) is set to true.
This is a list of items, so I’m doing a for each in the list, then grabbing the property I’m checking HasImage
. If that is true, I want a checked box for each item.
I’m getting the error
Argument type ‘bool’ is not assignable to parameter type system.linq.expressions.expression-system.func rma-vm,bool
What exactly is going on?
My code:
@foreach (var item in model.rmalist)
<td>@Html.CheckBoxFor(item.HasImage)<td>
Try this
This doesn’t work because “HasImage” is inside a list of RmaObjects, M => m.RmaObjects is all that shows up, because the hasimage property is inside of it. I thought doing the foreach loop would clear it up but I guess not.