protected void Page_Load(object sender, EventArgs e) { int ProjId = Convert.ToInt32(Session["ProjId"]); IsometricSummaryMatWiselReport reports = new IsometricSummaryMatWiselReport(); reports.ReportParameters[0].Value = ProjId; //report.ReportParameters[0].Value = ProjId; ReportViewer1.ReportSource = reports; }
public void GetSgSummaryMaterialWisePDF(int ProjId) { Random random = new Random(); int fileId = random.Next(1000, 9999); string fileName = $"report_{fileId}.pdf"; string filePath = $@"C:\Temp\{fileName}"; IsometricSummaryMatWiselReport report = new IsometricSummaryMatWiselReport(); Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); report.ReportParameters[0].Value = ProjId; Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null); FileStream fs = new FileStream(filePath, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}"); HttpContext.Current.Response.TransmitFile(filePath); HttpContext.Current.Response.End(); }