[英]Use DisplayFormat to show 3 decimal places
我是.NET的新手。 我無法弄清楚在我的視圖中顯示三位小數的正確語法。
在我的模型中,我目前有:
<<Display(name:="Straight Rate")>
Public Property StraighRate() As Decimal
Get
Return mStraightRate
End Get
Set(ByVal value As Decimal)
mStraightRate = value
End Set
End Property
我知道我需要在模型中使用DisplayFormat,但是我無法弄清楚將使其工作的語法。
在模型中添加DisplayFormat的語法后,是否需要在視圖中執行其他任何操作?
這是我目前的觀點:
@Html.DisplayFor(Function(modelItem) currentItem.StraightRate)
使用DisplayFormatAttribute
。 DataFormatString
屬性確定值如何在DisplayTemplate
顯示
<Display(name:="Straight Rate")>
<DisplayFormat(DataFormatString:="{0:0.000}")>
Public Property StraighRate() As Decimal
mStraightRate = Format(value, ##.##.##)
您可以使用英鎊的跡象,你怎么想的貨幣,你可以簡單地把.. mStraightRate = Format(value,"currency")
也有更多的選擇,但對自定義使用頂端。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.