I have Price field in my view. it have the following values 2.5 and 44.
I want to display this value to 2.50 and 44.00 i use the following code
@{decimal prolistprice = decimal.Parse(item.OtherFields["Price"].ToString());}
$@Math.Round(prolistprice, 2, MidpointRounding.AwayFromZero)
in which item.OtherFields["price"] is a object i convert it to string and then decimal
but Math.round is not working it shows 2.5 and 44 only..
Can anyone help this
解决方案
Math.Round does just that - round.
To format the number you may use .ToString(formatString) like so:
item.OtherFields["price"].ToString("0.00")