public void reportForX(string SYTERM)//Dynamic SYTerm, By Department,
    {
        SqlCommand cmd = new SqlCommand("SELECT FORMAT(dbo.AcademicAdviserConsultations.ConsultationDateTime, 'MMMM dd yyyy') as [Date], dbo.Student.StudentName, dbo.Student.StudentNumber, dbo.StudentStatus.Program, dbo.AcademicAdviserConsultations.NatureOfAdvising, ActionTaken,dbo.AcademicAdviser.FName + ' ' + dbo.AcademicAdviser.LName as [Academic Adviser] FROM dbo.AcademicAdviser INNER JOIN dbo.AcademicAdviserConsultations ON dbo.AcademicAdviser.AAdviserId = dbo.AcademicAdviserConsultations.AAdviserId INNER JOIN dbo.Student ON dbo.AcademicAdviserConsultations.StudentNumber = dbo.Student.StudentNumber INNER JOIN dbo.StudentStatus ON dbo.Student.StudentNumber = dbo.StudentStatus.StudentNumber WHERE dbo.AcademicAdviser.[Status] = 'ACTIVE' AND dbo.AcademicAdviserConsultations.SYTerm = '" + SYTERM + "' AND dbo.StudentStatus.[SYTerm] = '" + SYTERM + "' ORDER BY [Academic Adviser], ConsultationDateTime");

        Session["Filename"]  = "AcademicAdvisersSlip";
        GridViewX.DataSource = Class2.getDataSet(cmd);
        GridViewX.DataBind();
    }
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        try
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=(" + Session["SYTerm"].ToString().Replace(" ", string.Empty) + ")" + Session["Filename"] + ".xls");
            Response.ContentType = "application/vnd.xls";
            System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);

            if (GridViewZ.Visible == true)
            {
                GridViewZ.RenderControl(htmlWrite);
            }
            else if (GridViewEE.Visible == true)
            {
                GridViewEE.RenderControl(htmlWrite);
            }
            else if (GridViewFF.Visible == true)
            {
                GridViewFF.RenderControl(htmlWrite);
            }
            else if (GridViewGG.Visible == true)
            {
                GridViewGG.RenderControl(htmlWrite);
            }
            else if (GridViewR.Visible == true)
            {
                GridViewR.RenderControl(htmlWrite);
            }
            else if (GridViewS.Visible == true)
            {
                GridViewS.RenderControl(htmlWrite);
            }
            else if (GridViewX.Visible == true)
            {
                GridViewX.RenderControl(htmlWrite);
            }

            /*
             * else if(GridViewY.Visible == true)
             * {
             *  GridViewY.RenderControl(htmlWrite);
             * }*/

            Response.Write(stringWrite.ToString());
            Response.End();
        }
        catch (Exception ex)
        {
        }
    }
    protected void btnExportToPDF_Click(object sender, EventArgs e)
    {
        try
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=(" + Session["SYTerm"].ToString().Replace(" ", string.Empty) + ")" + Session["Filename"] + ".pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            if (GridViewZ.Visible == true)
            {
                GridViewZ.RenderControl(hw);
            }
            else if (GridViewEE.Visible == true)
            {
                /*GridViewEE.AllowPaging = false;
                 * GridViewEE.DataBind();*/
                GridViewEE.RenderControl(hw);
            }
            else if (GridViewFF.Visible == true)
            {
                GridViewFF.RenderControl(hw);
            }
            else if (GridViewGG.Visible == true)
            {
                GridViewGG.RenderControl(hw);
            }
            else if (GridViewR.Visible == true)
            {
                GridViewR.RenderControl(hw);
            }
            else if (GridViewS.Visible == true)
            {
                GridViewS.RenderControl(hw);
            }
            else if (GridViewX.Visible == true)
            {
                GridViewX.RenderControl(hw);
            }

            /*
             * else if(GridViewY.Visible == true)
             * {
             *  GridViewY.RenderControl(htmlWrite);
             * }*/

            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();
        }
        catch (Exception ex)
        {
        }
    }