简体   繁体   English

如何在mvc3 / razor / webgrid中将计算值格式化为十进制格式?

[英]How to format calculated value as decimal in mvc3/razor/webgrid?

如何在mvc3 / razor / webgrid helper中将其显示为小数?

grid.Column("DecimalValue", format: @<text>@((@item.SomeInt / @item.SomeInt2))</text>)

You will need to cast to decimal, or you will only do integer arithmetic, which by definition returns an integer. 您将需要强制转换为小数,或者仅执行整数运算,根据定义,该运算将返回整数。

Not quite sure razor syntax will allow this (if not, use a code block @{}) 不太确定剃刀的语法会允许这样做(如果不允许,请使用代码块@ {})

@(decimal)item.SomeInt / @item.SomeInt2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM