how can i have a CheckBoxFor using int?
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)
For some reason the response above gave me errors but based on the same idea I've change the code like this:
public int IntValue { get; set; }
public bool BoolValue
{
get { return IntValue == 1; }
set {
if(value)
IntValue = 1;
else
IntValue = 0;
}
}
and that work for me.