I'm using Html.TextBoxFor(model => model.field) which works fine, however it defaults to 0 for numbers, and to N/A for strings if they are not set, how can i possible change that such it doesn't show anything if the value is not set?
You have to make the values in your model nullable, like so:
public class Model
{
public int? Field { get; set; }
}
That way an empty value will map to the null value and vice versa.
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