2012-05-05 62 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(); 

    } 


} 

之后,问题就迎刃而解了。