简体   繁体   中英

Culture of thread for method render of LocalReport

I'm using a localreport object into an asp.net application. This report is fed by an array of object. So on the render of the report, some properties of the classe are called.

Class ClassForReport
{
  string Date
  {
    get{return _aDate.ToshortDateString();}
  }
}

Now the code for rendering and the problem:

//first of all, I change de culture for taking in account the choice of the user
CultureInfo ci = CultureInfo.CreateSpecificCulture(isoLanguageName_);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci; 
//Here, my culture is now: FR-be

MyLocalReport.render(...) // in this method, the property Date above is called. And when debugging I see that the culture is EN !!!

...
//and here, my culture is still Fr-be

So it seems that when the method render is called, it launch a thread and take the culture of the server and not the culture of the process.

The only workarround I see is changing my report to contains a date and then giving a parameter of culture and formating all my date in all my reports to the given culture...

So I realy hope there is a way to tell the report to take the curent culture of the asp thread and not taking some other culture comming from nowhere.

thx in advance

In " .rdlc " Designer on your ReportFile, set on the Report in Language property " =User!Language ".

<Report>
  ... 
  <Language>=User!Language</Language>
  ...
</Report>

then your System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); will work on the values in report.Render(...); like dates,etc.

Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM