SAP Knowledge Base Article - Public

1306832 - Save-To window does not popup while exporting Crystal reports from .Net application.

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

  1. Design a report with parameters in it.
  2. Create a simple application with a Crystal Report Viewer on it.
  3. Using the Report Document, load the above report.
  4. Assign the Report Document object to the CrystalReportViewer.
  5. Run the application.
  6. Enter the parameters prompted, so that first page of the report appears.
  7. Click the export button on the Crystal Report Viewer toolbar, it will open up a new window.
  8. Select any format to export the report and click OK button.
  9. 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 , Problem

Product

SAP Crystal Reports, version for Visual Studio .NET 2008