Skip to Content
0
Former Member
Sep 12, 2011 at 10:41 AM

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

15 Views

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