Cerkvenic
Cerkvenic

Reputation: 377

RDLC formatting number according to locale settings

I am using RDLC reports on my web page to show some data as a local report. Everything works fine but the numbers are not formatted according to my locale culture settings (sl-SI) and I am running out of ideas how to fix the problem.

Example. I have a TextBox of value:

where “Count” is integer, and the format is:

In the code before the report is populated I set the culture:

    CultureInfo cInfo = new CultureInfo(“sl-SI”, false);
    Thread.CurrentThread.CurrentCulture = cInfo;
    Thread.CurrentThread.CurrentUICulture = cInfo; 

After this I would expect the text box value to be formatted 2.358 as required by the sl-SI culture but is 2,358.

Does anybody knows what I am doing wrong?

Thank you!

Upvotes: 1

Views: 10894

Answers (2)

Heinzi
Heinzi

Reputation: 172230

As an addition to Cerkenvic's great answer:

If you set the report's Language property to the following expression:

=User!Language

the RDLC engine will use the current thread's locale without you having to implement and fill a custom report parameter.

Upvotes: 0

Cerkvenic
Cerkvenic

Reputation: 377

I found the solution of this problem, and would like to shere it with the comunity:

  1. Go to the RDLC report.
  2. Click on the report field (not on the content)
  3. Go to the "Properties"
  4. Set the "Language" property to your locale (in my case "sl-SI").

That's all.

You can do it programmatically by setting the property "Language" to equal a report parameter having the value of the wished locale ....

Thak you ...

Upvotes: 9

Related Questions