gpt4 book ai didi

c# - LocalReport 方法呈现的线程文化

转载 作者:太空狗 更新时间:2023-10-30 00:46:30 26 4
gpt4 key购买 nike

我在 asp.net 应用程序中使用 localreport 对象。该报告由一组对象提供。所以在报告的呈现上,类的一些属性被调用。

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

现在是渲染代码和问题:

//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

所以看起来当方法 render 被调用时,它启动一个线程并采用服务器的文化而不是进程的文化。

我看到的唯一解决方法是将我的报告更改为包含一个日期,然后提供文化参数并将我所有报告中的所有日期格式化为给定的文化...

所以我真的希望有一种方法可以告诉报告采用 asp 线程的当前文化,而不是采用其他不知从何而来的文化。

提前谢谢

最佳答案

在 ReportFile 的“.rdlcDesigner 中,在Language 属性中设置 Report“=User!Language”。

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

然后是你的 System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");将处理 report.Render(...); 中的值,例如日期等。

干杯。

关于c# - LocalReport 方法呈现的线程文化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3164548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com