Search code examples
vb.netmodel-view-controllercheckboxfor

Error When Using CheckBoxFor in MVC with VB


I'm trying to create a checkbox with the following code:

@Html.CheckBoxFor(Function(model) model.PotentialDishmachineProducts)
@Html.ValidationMessageFor(Function(model) model.PotentialDishmachineProducts)

But, it keeps throwing up the error:

"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."

Here's the property in the model:

Public Property PotentialDishmachineProducts As String

It is not tied into a database or anything. Any ideas how to get this checkbox to work? Btw, if it's not obvious, I am brand new to MVC and VB.

Thanks!!


Solution

  • Switched As String to As Boolean.