MVC3 Decimal truncated to 2 decimal places on edit

前端 未结 3 1493
一向
一向 2020-12-05 02:48

I\'m running MVC3 with Razor and noticed that decimal values are truncated to 2 decimal places when in edit mode. I\'ve managed to get round it by annotating my property wit

3条回答
  •  臣服心动
    2020-12-05 03:17

    IMO, this article has a better option:

    html-editorfor-with-3-decimal-places

    I used this code to display up to 4 decimal digits in my EditFor:

        [Display(Name = "Discount Percentage")]
        [Range(0, 100.0)]
        [DisplayFormat(DataFormatString="{0:0.0000}", ApplyFormatInEditMode=true)]
        public Decimal? DiscountPercent { get; set; }
    

提交回复
热议问题