Solution 1 :

Html.CheckBoxFor get Func from inputs . You should try this :

@Html.CheckBoxFor(m=> m.HasImage)

Solution 2 :

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)

Problem :

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

enter image description here

What exactly is going on?

My code:

@foreach (var item in model.rmalist)


Comment posted by…

Try this

Comment posted by st0rch1991

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.