public void BindGrid()
    {
        try
        {
            if (ViewState["Flag"].ToString() == "DP")
            {
                divDetails.Visible = true;
                DIV_TERM.Visible   = false;
                DIV_MAT.Visible    = false;
                divPigmy.Visible   = false;
                DivSRO.Visible     = false;
                LG.Getinfotable(grdDetails, Session["BRCD"].ToString(), LG.openDay(Session["BRCD"].ToString()), ViewState["Flag"].ToString());

                FL = "Insert";//Dhanya Shetty
                string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "Dash_view _" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
            }

            else if (ViewState["Flag"].ToString() == "MAT")
            {
                divDetails.Visible = false;
                DIV_TERM.Visible   = false;
                DIV_MAT.Visible    = true;
                divPigmy.Visible   = false;
                DivSRO.Visible     = false;
                LG.Getinfotable(GrdMatDetails, Session["BRCD"].ToString(), LG.openDay(Session["BRCD"].ToString()), ViewState["Flag"].ToString());

                FL = "Insert";//Dhanya Shetty
                string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "Dash_Mat_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
            }
            else if (ViewState["Flag"].ToString() == "PIGMY")
            {
                divDetails.Visible = false;
                DIV_TERM.Visible   = false;
                DIV_MAT.Visible    = false;
                divPigmy.Visible   = true;
                DivSRO.Visible     = false;
                LG.Getinfotable(GridPigmy, Session["BRCD"].ToString(), LG.openDay(Session["BRCD"].ToString()), ViewState["Flag"].ToString());

                FL = "Insert";//Dhanya Shetty
                string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "Dash_Mat_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
            }
            else if (ViewState["Flag"].ToString() == "SRO")
            {
                divDetails.Visible = false;
                DIV_TERM.Visible   = false;
                DIV_MAT.Visible    = false;
                divPigmy.Visible   = false;
                DivSRO.Visible     = true;

                TxtFDate.Text = string.IsNullOrEmpty(Session["FDate"].ToString()) ? "0" : Session["FDate"].ToString();
                TxtTDate.Text = string.IsNullOrEmpty(Session["TDate"].ToString()) ? "0" : Session["TDate"].ToString();
                SRO.GetSROInfoDT(GridSRO, Session["BRCD"].ToString(), TxtFDate.Text.ToString(), TxtTDate.Text.ToString());

                CLM.LOGDETAILS("Insert", Session["BRCD"].ToString(), Session["MID"].ToString(), "Dash_Mat_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
            }
            else if (ViewState["Flag"].ToString() == "ABLR")
            {
                if (Session["BRCD"].ToString() == "1")
                {
                    string redirectURL = "FrmRView.aspx?BRCD=" + "0000" + "&AsOnDate=" + Session["EntryDate"].ToString() + "&rptname=Isp_AVS0029.rdlc" + "";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + redirectURL + "','_blank')", true);
                }
                else
                {
                    string redirectURL = "FrmRView.aspx?BRCD=" + Session["BRCD"].ToString() + "&AsOnDate=" + Session["EntryDate"].ToString() + "&rptname=Isp_AVS0029.rdlc" + "";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + redirectURL + "','_blank')", true);
                }
            }
            else
            {
                DIV_TERM.Visible   = false;
                divDetails.Visible = true;
                DIV_MAT.Visible    = false;
                divPigmy.Visible   = false;
                DivSRO.Visible     = false;
                LG.Getinfotable(grdDetails, Session["BRCD"].ToString(), LG.openDay(Session["BRCD"].ToString()), ViewState["Flag"].ToString());

                FL = "Insert";//Dhanya Shetty
                string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "Dash_view _" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
            }
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }