protected void WordBtn_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         DataTable dataTable = (DataTable)Session["dataTable"];
         ExportStaffGrid.AllowPaging           = false;
         ExportStaffGrid.HeaderStyle.ForeColor = System.Drawing.Color.White;
         ExportStaffGrid.BorderWidth           = 0;
         ExportStaffGrid.DataSource            = dataTable;
         ExportStaffGrid.DataBind();
         Response.ClearContent();
         Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "StaffDetails.doc"));
         Response.Charset     = "";
         Response.ContentType = "application/ms-word";
         StringWriter   sw  = new StringWriter();
         HtmlTextWriter htw = new HtmlTextWriter(sw);
         //Applying stlye to gridview header cells
         for (int i = 0; i < ExportStaffGrid.HeaderRow.Cells.Count; i++)
         {
             ExportStaffGrid.HeaderRow.Cells[i].Style.Add("background-color", "Black");
         }
         ExportStaffGrid.RenderControl(htw);
         Response.Write(sw.ToString());
         Response.End();
     }
     catch (Exception ex)
     {
         MessageBoxShow(ex.Message.ToString());
     }
 }
        protected void PdfBtn_Click(object sender, ImageClickEventArgs e)
        {
            Response.ContentType = "application/pdf";

            Response.AddHeader("content-disposition", "attachment;filename=StaffEvaluation.pdf");

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            StringWriter sw = new StringWriter();

            HtmlTextWriter hw = new HtmlTextWriter(sw);

            ExportStaffGrid.AllowPaging = false;

            ExportStaffGrid.DataBind();

            ExportStaffGrid.RenderControl(hw);

            ExportStaffGrid.HeaderRow.Style.Add("width", "15%");

            ExportStaffGrid.HeaderRow.Style.Add("font-size", "10px");

            ExportStaffGrid.Style.Add("text-decoration", "none");

            ExportStaffGrid.Style.Add("font-family", "Arial, Helvetica, sans-serif;");

            ExportStaffGrid.Style.Add("font-size", "8px");

            StringReader sr = new StringReader(sw.ToString());

            Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);

            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

            pdfDoc.Open();

            htmlparser.Parse(sr);

            pdfDoc.Close();

            Response.Write(pdfDoc);

            Response.End();
        }