I have a crystal report viewer bound as such:
When I bind the viewer programmaticall y the export button on the toolbar does nothing. It just reloads the page and the report disappears. In fact all of the buttons on the toolbar cause the page to reload and the report disappears.
So I am trying to make a button that will export the report to PDF format. The button looks like this:
Ive tried like 10 different ways I've found through google to export the report but they all give me the same errors. ExportToHttpRes ponse, ExportToDisk, and ExportToStream, all give me the same error.
The error always says Missing Parameter Values
The console says:
CrystalDecision s.CrystalReport s.Engine.Parame terFieldCurrent ValueException' occurred in CrystalDecision s.ReportAppServ er.DataSetConve rsion.dll
So yeah I just cannot find a way to export this thing...any suggestions would be appreciated
Code:
ReportDocument rd = getReportDocument(); DESClass des = new DESClass(key, iv); string encrypted; ParameterDiscreteValue crParameterDiscreteValue; ParameterFieldDefinitions crParameterFieldDefinitions; ParameterFieldDefinition crParameterFieldLocation; ParameterValues crParameterValues; // Get the report parameters collection. crParameterFieldDefinitions = rd.DataDefinition.ParameterFields; // Add parameter value - SSN crParameterFieldLocation = crParameterFieldDefinitions["@SSN"]; crParameterValues = crParameterFieldLocation.CurrentValues; crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); encrypted = des.Encrypt(txtSSN.Text); string script = "alert('" + encrypted + "');"; ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "testing", script, true); crParameterDiscreteValue.Value = encrypted; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldLocation.ApplyCurrentValues(crParameterValues); // Add parameter value @FromDate crParameterFieldLocation = crParameterFieldDefinitions["@FromDate"]; crParameterValues = crParameterFieldLocation.CurrentValues; crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameterDiscreteValue.Value = txtFromDate.Text; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldLocation.ApplyCurrentValues(crParameterValues); // Add parameter value @ToDate crParameterFieldLocation = crParameterFieldDefinitions["@ToDate"]; crParameterValues = crParameterFieldLocation.CurrentValues; crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameterDiscreteValue.Value = txtToDate.Text; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldLocation.ApplyCurrentValues(crParameterValues); // Add parameter value @Department crParameterFieldLocation = crParameterFieldDefinitions["@Department"]; crParameterValues = crParameterFieldLocation.CurrentValues; crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameterDiscreteValue.Value = txtDepartment.Text; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldLocation.ApplyCurrentValues(crParameterValues); // Add parameter value @SSN crParameterFieldLocation = crParameterFieldDefinitions["@County"]; crParameterValues = crParameterFieldLocation.CurrentValues; crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameterDiscreteValue.Value = txtCounty.Text; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldLocation.ApplyCurrentValues(crParameterValues); //bind reportsource CrystalReportViewer1.ReportSource = rd;
So I am trying to make a button that will export the report to PDF format. The button looks like this:
Code:
// Get the report document ReportDocument repDoc = getReportDocument(); MemoryStream oStream; // using System.IO oStream = (MemoryStream)repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.BinaryWrite(oStream.ToArray()); Response.End();
The error always says Missing Parameter Values
The console says:
CrystalDecision s.CrystalReport s.Engine.Parame terFieldCurrent ValueException' occurred in CrystalDecision s.ReportAppServ er.DataSetConve rsion.dll
So yeah I just cannot find a way to export this thing...any suggestions would be appreciated