cancel
Showing results for 
Search instead for 
Did you mean: 

Printing results in a report with no data. CR13.0.1, CR4VS2010, c#.net web

Former Member
0 Kudos

I'm using CR 13.0.1 and CR4VS2010 on a C#.net website.

I've setup CR on my pc and have reports running fine and dispalying correctly in the web viewer. My problem lies when trying to either print or export the report. The report shows all the formatting and data in the viewer but when i click print or export it seems to lose the data. The various images and text fields are printed/exported but any of the data fields are not printed at all.

protected void Page_Load(object sender, EventArgs e)
    {
        //Create Report Object and load the relevant report file
        ReportDocument crReportDoc = new ReportDocument();
        crReportDoc.Load(HttpContext.Current.Server.MapPath("invoice.rpt"));
        
        //Set the database connection details, so the user doesn't require them
        crReportDoc.SetDatabaseLogon("username", "password"); 
       
        //Setup any/all parameters for the report
        crReportDoc.SetParameterValue("@dealerID", CMS.CMSHelper.CMSContext.CurrentUser.GetValue("DealerID"));
        crReportDoc.SetParameterValue("@dateFrom", Request.QueryString["dateFrom"]);
        crReportDoc.SetParameterValue("@dateTo", Request.QueryString["dateTo"]);

        //configure reportdocument
        crReportDoc.ReportOptions.EnableSaveDataWithReport = true;

        //Configure the reportviewer
        CrystalReportViewer1.HasCrystalLogo = false;
        CrystalReportViewer1.HasPrintButton = true;
        CrystalReportViewer1.PrintMode = PrintMode.Pdf;
        CrystalReportViewer1.HasExportButton = true;
        CrystalReportViewer1.HasDrillUpButton = false;
        CrystalReportViewer1.HasToggleGroupTreeButton = false;
        CrystalReportViewer1.HasToggleParameterPanelButton = false;
        CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
        CrystalReportViewer1.AutoDataBind = true;
        CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;

        //Tie the reportdocument to the viewer object
        CrystalReportViewer1.ReportSource = crReportDoc;
    }

For the dealerID parameter the CMS.CMSHelper.etc bit is part of the CMS system the website is built with (kentico).

Can anyone suggest something that I have not done here that would explain why the report appears correctly on screen (through the webviewer) but fails to include any data when its printed or exported

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Can't explain it, but here are a few tests;

1) Try to print a saved data report

2) Try to print a report that is not using parameters

3) Try a different printer driver as "default"

4) Enable the option "Dissociate Formatting Page Size and Printer Paper Size" on the report

5) What format do you export to?

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Answers (1)

Answers (1)

Former Member
0 Kudos

I've got it working now.

The code above wasnt saving the reportdocument to the session so presumably not picking up anything when trying to print. Added in some code to save to the session/restore from the session on a postback and its now working fine.

former_member183750
Active Contributor
0 Kudos

Happy it's working now. And many thanks for posting the solution.

- Ludek