protected void btnExportSubCategoryDataPDF_Click(object sender, ImageClickEventArgs e) { GridSubCategory.AllowPaging = false; GridSubCategory.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=CuttingListMaterialsbySubCategory " + DateTime.Now.ToShortDateString() + ".pdf"); GridSubCategory.GridLines = GridLines.Horizontal; GridSubCategory.HeaderStyle.Font.Bold = true; GridSubCategory.HeaderStyle.ForeColor = System.Drawing.Color.DarkBlue; GridSubCategory.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(); GridSubCategory.AllowPaging = true; GridSubCategory.DataBind(); }
protected void btnExportSubCategoryDataExcel_Click(object sender, ImageClickEventArgs e) { GridSubCategory.AllowPaging = false; GridSubCategory.DataBind(); Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Charset = ""; string FileName = "CuttingListMaterialsBySubCategory " + 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); GridSubCategory.GridLines = GridLines.Both; GridSubCategory.HeaderStyle.Font.Bold = true; GridSubCategory.RenderControl(htmltextwrtter); Response.Write(strwritter.ToString()); Response.End(); GridSubCategory.AllowPaging = true; GridSubCategory.DataBind(); }
protected void btnGetDataBySubCategory_Click(object sender, EventArgs e) { GridSubCategory.DataBind(); Page.ClientScript.RegisterStartupScript(this.GetType(), "EnterText", "SelectCategory();", true); }