2012-05-05 59 views
2

我的報表使用Crystal Report Viewer顯示在aspx文件中,點擊按鈕將報表導出爲PDF後,所有數據都將丟失,並且只有圖形保留在頁面中。可能是什麼問題?將水晶報表導出爲PDF導致數據丟失

可以幫助PLZ

回答

2

實際上你點擊的CrystalReportViewer所有動作觸發回發。大多數時候,人們並沒有在會話中存儲reportdocument,而是將其重新分配給查看者。在這個答案中,我演示瞭如何將現有代碼移動到存儲reportdocument的模型中,以防止導出/打印/分頁/等問題。

crystal report toolbar button not working

0

對於我的web項目,我分配的會話數據到ReportSource在Page_Init()方法在aspx文件。因爲報表數據是通過會話數據從另一個頁面傳輸的。

void Page_Init(object sender, EventArgs e) 
{ 

    this.rptViewer.ReportSource = Session["ReportData"]; 
} 

而且,做 「aspx.cs」 文件的Page_Load方法相同,如下所示:

protected void Page_Load(object sender, EventArgs e) 
{ 

    if (!IsPostBack) 
    { 


     rptViewer.Visible = true; 
     this.rptViewer.ReportSource = Session["ReportData"]; 
     this.rptViewer.ShowFirstPage(); 

    } 


} 

之後,問題就迎刃而解了。