Symptom
'Save To' window does not appear after clicking Export button on the viewer toolbar.
Environment
Valid for all Versions of CR for .NET
Reproducing the Issue
Design a report with parameters in it.
Create a simple application with a Crystal Report Viewer on it.
Using the Report Document, load the above report.
Assign the Report Document object to the CrystalReportViewer.
Run the application.
Enter the parameters prompted, so that first page of the report appears.
Click the export button on the Crystal Report Viewer toolbar, it will open up a new window.
Select any format to export the report and click OK button.
Report does not get exported and the same parameter-prompting screen reappears.
Windows XP Professional SP2.
Visual Studio 2008 Professional.
Crystal Reports Basic for Visual Studio 2008.
Cause
Whenever the export button on the toolbar is clicked, a second request is sent to the server resulting in the ReportDocument object being reinitialized. Hence it loses all the previously stored data or states.
For example - After clicking the export button on the toolbar, the report on the background web-page is replaced by the parameter prompting screen.
Resolution
In the Page_Load method, use this code for viewing the report:
if (!IsPostBack)
{
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("CrystalReport.rpt"));
//For setting the parameters through code
rd.SetParameterValue("Parameter Name", "Value");
CrystalReportViewer1.ReportSource = rd;
}
IsPostBack method will prevent the ReportDocument from getting reinitialized. Due to this the ReportDocument object can retain previously stored data after clicking on the export button.
Keywords
VS, CR
, KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , ProblemProduct
SAP Crystal Reports, version for Visual Studio .NET 2008