In one of tables I am using a Data Type of decimal(5,1)
. I have looked at this reference . It specifically says D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.
So, the property in my table that is of type decimal(5,1)
is auto-filled at 0.00 on my Create page in my web application. How are the two '0's possible if it should only allow 1 digit to the right of the decimal point?
got the answer, in my Model I need to do:
[Display(Name = "Total:")]
[DisplayFormat(DataFormatString = "{0:0.0}", ApplyFormatInEditMode = true)] /*Part I needed*/
[Required(ErrorMessage = "This field is required!")]
public decimal Total { get; set; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.