genxgeek
genxgeek

Reputation: 13357

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

How can I get this to show as a decimal in mvc3/razor/webgrid helper?

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

Upvotes: 0

Views: 1093

Answers (1)

driis
driis

Reputation: 164291

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

Upvotes: 1

Related Questions