protected void btnPDFExport_Click(object sender, ImageClickEventArgs e) { ReportDocument rd = new ReportDocument(); string rptFile = Server.MapPath("/IFF_MAIN/CrystalReportResources/rpt/AESList.rpt"); string xsdFile = Server.MapPath("/IFF_MAIN/CrystalReportResources/xsd/AESList.xsd"); AESListDS = new FreightEasy.DataManager.FreightEasyData(); string selectSQL = @"SELECT a.*, b.dba_name AS consignee_name, c.dba_name AS inter_consignee_name FROM aes_master a LEFT OUTER JOIN organization b ON (a.elt_account_number=b.elt_account_number AND a.consignee_acct=b.org_account_number) LEFT OUTER JOIN organization c ON (a.elt_account_number=c.elt_account_number AND a.inter_consignee_acct=c.org_account_number) WHERE a.elt_account_number=" + elt_account_number + " AND ISNULL(file_type,'')='AE' ORDER BY a.last_modified desc"; AESListDS.AddToDataSet("AESList", selectSQL); try { rd.Load(rptFile, OpenReportMethod.OpenReportByTempCopy); rd.SetDataSource(AESListDS.Copy()); AESListDS.WriteXmlSchema(xsdFile); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-disposition", "attachment;filename=AESList.pdf"); MemoryStream oStream = (MemoryStream)rd.ExportToStream(ExportFormatType.PortableDocFormat); Response.BinaryWrite(oStream.ToArray()); } catch { } finally { rd.Close(); Response.Flush(); Response.End(); } }