S.p
S.p

Reputation: 1059

how to display amount with currency format in mvc3

I have created a table for tax ranges. Now I want to display the amounts formatted like so: $100,000. How can I do this?

Upvotes: 35

Views: 45423

Answers (3)

Vlad P
Vlad P

Reputation: 11

Or shorter version @amount.ToString("C")

Upvotes: 1

Ashbel
Ashbel

Reputation: 335

You could add this in your model, the currency symbol will be displayed anytime you reference that field

[DisplayFormat(DataFormatString = "{0:C}", ApplyFormatInEditMode = true)]
    public decimal DebitAmount { get; set; }

Upvotes: 21

Raxr
Raxr

Reputation: 985

You could try this format, and replace amount with custom value.

@string.Format("{0:C}", amount);

Upvotes: 66

Related Questions