protected void btnExportSupplierPDF_Click(object sender, EventArgs e) { GridSupplierData.AllowPaging = false; GridSupplierData.DataBind(); Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=CuttingListMaterialsbySupplier " + DateTime.Now.ToShortDateString() + ".pdf"); GridSupplierData.GridLines = GridLines.Horizontal; GridSupplierData.HeaderStyle.Font.Bold = true; GridSupplierData.HeaderStyle.ForeColor = System.Drawing.Color.DarkBlue; GridSupplierData.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); GridSupplierData.AllowPaging = true; GridSupplierData.DataBind(); }
protected void btnSupplierData_Click(object sender, EventArgs e) { GridSupplierData.AllowPaging = false; GridSupplierData.DataBind(); Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Charset = ""; string FileName = "CuttingListMaterialsBySupplier " + DateTime.Now.ToShortDateString() + ".xls"; StringWriter strwritter = new StringWriter(); HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName); GridSupplierData.GridLines = GridLines.Both; GridSupplierData.HeaderStyle.Font.Bold = true; GridSupplierData.RenderControl(htmltextwrtter); Response.Write(strwritter.ToString()); Response.End(); GridSupplierData.AllowPaging = true; GridSupplierData.DataBind(); }
protected void btnGetSupplierData_Click(object sender, EventArgs e) { GridSupplierData.DataBind(); Page.ClientScript.RegisterStartupScript(this.GetType(), "EnterText", "SelectSupplier();", true); }