Format for currency (MXN) DataFormatString

2

I am applying in the model the DataformatString I wish that in the price of the products appear the cost separated by thousands with one (,) and that it appears without decimals. I was able to make decimals not appear but not to show the thousands separated by (,) since they appear separated by (.) And it seems to indicate cents instead of thousands.

Model

 [DisplayFormat(DataFormatString = "{0:$#,#}")]
 public double Price { get; set; }

Html

Precio: @Html.DisplayFor(Model => Model.Products.ElementAt(i).Price) MXN

APPEARS

  

Price: $ 17,572 MXN

My interest is to appear as follows

  

Price: $ 17,572 MXN

Before in the model I would put it in the following way if I remember correctly

[DisplayFormat(DataFormatString = "{0:C0}")]
 public double Price { get; set; }

but the currency appeared in Euros and I need it in Mexican currency and thousands to appear with commas and without decimals.

I hope you can help me:).

    
asked by ViA Alondra 20.08.2018 в 15:56
source

1 answer

3

What happens is that when you put [DisplayFormat(DataFormatString = "{0:C0}")] it takes the data of the zone in which your computer is configured by which I imagine you have it with the Spanish of Spain so that's why you get in Euros what you can do is to tell the system that you want to use the configuration of Mexico, within your web.config in the section system.web add the following tag:

  

<globalization culture="es-MX" uiCulture="es" />

This way it will be configured with Spanish Mexico, it will also help you if you publish it on a server / hosting from another country.

    
answered by 22.08.2018 / 19:20
source