On a button click I want to export the report as a PDF. I need to pass the shipmentId but its not getting passed in. Is my code wrong? My storedProcd is set up as a SQLDatasource in the report. the parameter is set as a string. the code ignored what I am passing in.
// Create report source
var reportSource = new Telerik.Reporting.UriReportSource
{
Uri = Server.MapPath("Manifest.trdp") // Replace "PathToYourReport" with the actual path to your report
};
// add parameters to report source
reportSource.Parameters.Add(new Telerik.Reporting.Parameter("@shipmentId", shipmentsId.Value.ToString()));
// Create report processor
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
// Render the report to PDF
var result = reportProcessor.RenderReport("PDF", reportSource, null);
if (result.HasErrors)
{
throw new Exception("There were errors during report processing: " + result.Errors[0].Message.ToString());
}
// Set the content type to PDF
Response.ContentType = "application/pdf";
// Write the PDF data to the output stream
Response.OutputStream.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
// End the response to force it to client
Response.End();