protected void GenerateQuarantineBoxReport(int rptId, string name) { try { rptDoc = new ReportDocument(); CrystalReportViewer1.HasToggleGroupTreeButton = false; CrystalReportViewer1.BestFitPage = false; CrystalReportViewer1.Width = 920; DataTable dt = us_dll.GetReportData("dbo.spProductInvty"); if (dt.Rows.Count > 0) { rptDoc.Load(Server.MapPath("~/Reports/ProductInvty.rpt")); rptDoc.SetDataSource(dt); rptDoc.SetDatabaseLogon("sa", "Pass2012", "GBLNJ4", "GPLS"); rptDoc.DataSourceConnections[0].SetConnection("GBLNJ4", "GPLS", "sa", "Pass2012"); //CrystalReportViewer1.Page.Title = name; rptDoc.SummaryInfo.ReportTitle = name; // rptDoc.DataDefinition.FormulaFields["cTitle"].Text = "'" + name + "'"; CrystalReportViewer1.ReportSource = rptDoc; Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, name); CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None; CrystalReportViewer1.SeparatePages = true; CrystalReportViewer1.DataBind(); CrystalReportViewer1.HasExportButton = false; Response.Flush(); Response.Close(); } else { ErrorMessage("Current selection does not have data"); } } catch (System.Threading.ThreadAbortException) { // ignore it } catch (Exception ex) { ErrorMessage(ex.Message); } }