[RESOLVED]Currency sysmbol in MVC 5 razor view?

Hi,

I have datatype as like below in my model

[Display(Name = "Salary")]
[DataType(DataType.Currency)]
public decimal? Salary { get; set; }

and in my web.config i have

<globalization culture="en-IN"/>

But still showing $ symbol.

Any more setting to be done?

Try this

<globalization uiculture = "en" culture="en-IN"/>

Hi,

Try these codes:

[Display(Name = "Salary")]
[DataType(DataType.Currency)]
[DisplayFormat(NullDisplayText = "n/a", ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
public decimal? Salary { get; set; }

And Web.config:

<globalization culture="auto" uiCulture="auto" />

This config is automatically based on your browser language setting, or on IE based on OS language setting,

Al these code has been used on my projects.

Have fun

Thanks.

But my culture depends on user selection from dropdown and i don’t want culture info to come from browser or web.config file.

Hi,

You could change the culture in the action.

public ActionResult Index(string cultureinfo)
{
      CultureInfo culture = new CultureInfo(cultureinfo);
      Thread.CurrentThread.CurrentCulture = culture;
      Thread.CurrentThread.CurrentUICulture = culture;
}

Best Regards

Starain

Leave a Reply