I have a view model with a couple of properties that are not displaying as desired. One of the properties is of type datetime. The other is an int. In my Create view, the datetime
appears with a default value of 1/1/0001 12:00:00 AM
and the int
has of default of 0
.
We want empty fields by default. How do I do this?
I already found [DefaultValue("")]
and found it does not address this issue.
Thanks!
ASP.NET MVC 4 RC
Try declaring the properties on your ViewModel as nullable using ?
public DateTime? DateValue { get; set; }
public int? IntValue { get; set; }
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