I am new to crystal report.I have designed the crystal report by following this link Crystal Report with SQL Stored Procedure Parameter and Visual Studio Actually i need to pass different ID(Input value of the SP) to the SP that i connected with the Crystal report.
This is the Code that i am Passing the ID to crystal report :
protected void Button1_Click(object sender, EventArgs e)
{
string QuotationID = ViewState["QUOTATION_ID"].ToString();
ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "@id";
paramDiscreteValue.Value = QuotationID;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
string reportPath = Server.MapPath("~/CrystalReport.rpt");
reportDocument.Load(reportPath);
CrystalReportViewer1.ReportSource = reportDocument;
}
But when ever i click the button it asking the ID ...
To set parameter on crystal I always do it this way:
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(reportPath);
reportDocument.SetParameterValue("@id", QuotationID);
if you want to convert your report to a pdf:
var exportOptions = reportDocument.ExportOptions;
exportOptions.ExportDestinationType = ExportDestinationType.NoDestination;
exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
var req = new ExportRequestContext {ExportInfo = exportOptions};
var stream = reportDocument.FormatEngine.ExportToStream(req);
this returns you back a filestream that you can open from the aspx page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.