2010-07-02 71 views
4

我正在使用本地報告對象到一個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 

如此看來,當該方法使被調用,它啓動一個線程,並採取了服務器的文化,而不是文化該過程。

我看到的唯一workarround正在改變我對報告中包含日期,然後給予文化的一個參數,並在格式化我所有的時間在我的特定文化的所有報告...

所以我真的希望有一種告訴報告採取asp線程的純文化的方式,而不是從其他文化中走出來。

提前

回答

7

THX在您ReportFile 「.rdlc設計師,在語言財產 「=User!Language」 上報告設置。

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

那麼你System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); 將在值工作在report.Render(...);像日期等。

乾杯。