My model contains a decimal column, I have checked inside Controller action it has decimal values like below:
0.69874
0.78562
Strange though, when they appear on web page, they are rounded and they become 0.70
My model class has this property as:
public virtual decimal Rate { get; set; }
Inside view code is:
<td>@(Html.DisplayFor(m=>row.Rate))</td>
Can you please guide why it is being round automatically and what I should do to stop this, I want to display what ever is real value.
Much thanks for your guidance and helping me.
Try adding a Display attribute on the property in question
[DisplayFormat(DataFormatString = "{0:F3}")]
public virtual decimal Rate { get; set; }
Here are more options for formats http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx
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.