0

In my locale settings->numbers/currency, the decimal symbol is set to a period. Yet when I use the following in a Razor view:

<td class="number-col">@Model.TendersReceived[i].Wq.ToString("N")</td>

It renders the number with a comma as a decimal separator. The issue isn't with a different machine for the web server, because I use my dev PC's IIS. Or does IIS follow some other local settings?

ProfK
  • 49,207
  • 121
  • 399
  • 775

1 Answers1

1

try this

@Model.TendersReceived[i].Wq.ToString("N2")

or

<td class="number-col">string.Format("{0:0.00}", @Model.TendersReceived[i].Wq)</td>
Laxmikant
  • 588
  • 4
  • 11
  • I like your solution, thanks, but your answer doesn't really address the root question. – ProfK Feb 18 '20 at 06:40
  • `@Model.TendersReceived[i].Wq.ToString("N2", CultureInfo.InvariantCulture)` does the job nicely, thanks. Just plain `N2` uses the IIS web site locale to determine the default decimal separator is a comma. – ProfK Mar 04 '20 at 04:37