JQuery Mobile
JQuery Mobile

Reputation: 6301

Formatting a Nullable Decimal in a Razor View in ASP.NET

I have an ASP.NET MVC app. This app is using Razor in the views. I am trying to display a decimal?. The twist on this is that I do NOT want to show decimals. In other words, if the nullable decimal value is 567.89, I just want to display 567. Currently, I have a plain old:

<div class="icon">@Model.Count</div>

This approach displays 567.89. How do I format this nullable decimal to only show the whole number portion?

Thank you!

Upvotes: 3

Views: 2562

Answers (1)

JayL
JayL

Reputation: 251

You can use String.Format to display the decimal? with out the decimals.

@String.Format("{0:0}", 567.89)

Will display 567

Upvotes: 2

Related Questions