I need help to build a CheckBoxFor for getting an int
value.
Something like:
@Html.CheckBoxForInt(m => m.foo.intValue)
It should be checked if intValue = 1
else not checked.
Why don't you expose a bool property in your model that converts to/from the int?
Something like this:
public bool BoolValue
{
get { return IntValue == 1; }
set { IntValue = value ? 1 : 0;}
}
public int IntValue { get; set; }
Then you could use it to create the checkbox
@Html.CheckBoxFor(m => m.foo.BoolValue)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With