我是.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
Run Code Online (Sandbox Code Playgroud)
我知道我需要在模型中使用DisplayFormat,但是我无法弄清楚将使其工作的语法。
在模型中添加DisplayFormat的语法后,是否需要在视图中执行其他任何操作?
这是我目前的观点:
@Html.DisplayFor(Function(modelItem) currentItem.StraightRate)
Run Code Online (Sandbox Code Playgroud)