Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display amount with currency format in mvc3

Tags:

razor

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?

like image 223
S.p Avatar asked Aug 01 '12 06:08

S.p


People also ask

How do you display currency format?

Tip: You can also press Ctrl+1 to open the Format Cells dialog box. In the Format Cells dialog box, in the Category list, click Currency or Accounting. In the Symbol box, click the currency symbol that you want. Note: If you want to display a monetary value without a currency symbol, you can click None.

How do I format USD?

It is composed of the country code ( US ), followed by the letter "D" for "dollar." Write the code first, followed by a non-breaking space and the dollar figure: USD 350 million.


2 Answers

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

@string.Format("{0:C}", amount); 
like image 130
Raxr Avatar answered Sep 20 '22 02:09

Raxr


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; } 
like image 37
Ashbel Avatar answered Sep 22 '22 02:09

Ashbel