private void BindGrid()
    {
        string dtFrmDate = "";

        if (string.IsNullOrEmpty(lblFrom.Text.Trim()) == false)
        {
            dtFrmDate = Common.ReturnDate(lblFrom.Text.Trim());
        }

        string dtTillDate = "";

        if (string.IsNullOrEmpty(lblTo.Text.Trim()) == false)
        {
            dtTillDate = Common.ReturnDate(lblTo.Text.Trim());
        }


        //DataTable dtTimeSheet = new DataTable();
        dtTimeSheet = timeSheetMgr.GET_TimeSheet(lblEmpId.Text.Trim(), mon.Trim(), lblYear.Text.Trim(), fisCalYrId, dtFrmDate, dtTillDate);

        dtWeekEnd = timeSheetMgr.GET_EMP_WeekEnd(lblEmpId.Text.Trim());

        dtHolidays = timeSheetMgr.GET_Holidays_YrDay(lblYear.Text.Trim(), dtFrmDate, dtTillDate);



        string GADCODE = "";

        DataTable dtCostRecData = objGADMgr.SelectCostRecoveryPlanData(fisCalYrId, lblEmpId.Text.Trim());

        grTimeSheet.DataSource = dtCostRecData;
        grTimeSheet.DataBind();

        int month = Convert.ToInt32(mon.Trim());// ddlMonth.SelectedValue.ToString());

        DataRow[] fTRow;
        string    strVDate = "";

        foreach (GridViewRow gRow in grTimeSheet.Rows)
        {
            GADCODE = grTimeSheet.DataKeys[gRow.DataItemIndex].Values[0].ToString().Trim();
            fTRow   = null;

            //Retriving GAD Percentage value from Table CostRecovery.
            foreach (DataRow row in dtCostRecData.Rows)
            {
                if (grTimeSheet.DataKeys[gRow.DataItemIndex].Values[0].ToString().Trim() == row["GADCODE"].ToString().Trim())
                {
                    switch (month)
                    {
                    case 1:
                        gRow.Cells[1].Text = row["JAN"].ToString().Trim();
                        break;

                    case 2:
                        gRow.Cells[1].Text = row["FEB"].ToString().Trim();
                        break;

                    case 3:
                        gRow.Cells[1].Text = row["MAR"].ToString().Trim();
                        break;

                    case 4:
                        gRow.Cells[1].Text = row["APR"].ToString().Trim();
                        break;

                    case 5:
                        gRow.Cells[1].Text = row["MAY"].ToString().Trim();
                        break;

                    case 6:
                        gRow.Cells[1].Text = row["JUN"].ToString().Trim();
                        break;

                    case 7:
                        gRow.Cells[1].Text = row["JUL"].ToString().Trim();
                        break;

                    case 8:
                        gRow.Cells[1].Text = row["AUG"].ToString().Trim();
                        break;

                    case 9:
                        gRow.Cells[1].Text = row["SEP"].ToString().Trim();
                        break;

                    case 10:
                        gRow.Cells[1].Text = row["OCT"].ToString().Trim();
                        break;

                    case 11:
                        gRow.Cells[1].Text = row["NOV"].ToString().Trim();
                        break;

                    case 12:
                        gRow.Cells[1].Text = row["DEC"].ToString().Trim();
                        break;
                    }
                }
            }


            DateTime dtVDate;
            string   vDay       = "";
            string   weekEndDay = "";
            DateTime holiDay;


            int aVal = 0;
            if (arl.Count == 30)
            {
                aVal = 6;
            }
            else if (arl.Count == 29)
            {
                aVal = 7;
            }
            else if (arl.Count == 28)
            {
                aVal = 8;
            }
            else
            {
                aVal = 5;
            }


            //Cross checking and filling the cell value from Table TimeSheet.
            for (int i = 0; i < grTimeSheet.Columns.Count - aVal; i++)
            {
                strVDate = "";
                fTRow    = null;
                strVDate = grTimeSheet.HeaderRow.Cells[i + 3].Text.Trim() + "/" + lblYear.Text.Trim(); // ddlYear.SelectedValue.Trim();
                strVDate = Common.ReturnDate(strVDate);

                dtVDate = Convert.ToDateTime(strVDate);
                vDay    = dtVDate.DayOfWeek.ToString();
                foreach (DataRow dtRw in dtWeekEnd.Rows)
                {
                    switch (vDay)
                    {
                    case "Sunday":
                        weekEndDay = dtRw["WESun"].ToString().Trim();
                        break;

                    case "Monday":
                        weekEndDay = dtRw["WEMon"].ToString().Trim();
                        break;

                    case "Tuesday":
                        weekEndDay = dtRw["WETues"].ToString().Trim();
                        break;

                    case "Wednesday":
                        weekEndDay = dtRw["WEWed"].ToString().Trim();
                        break;

                    case "Thursday":
                        weekEndDay = dtRw["WETue"].ToString().Trim();
                        break;

                    case "Friday":
                        weekEndDay = dtRw["WEFri"].ToString().Trim();
                        break;

                    case "Saturday":
                        weekEndDay = dtRw["WESat"].ToString().Trim();
                        break;
                    }
                }



                fTRow = dtTimeSheet.Select("GADCODE='" + GADCODE + "' AND VDate='" + strVDate + "'");
                gRow.Cells[2].Text = fTRow[0]["AccLine"].ToString().Trim();

                decimal allocatedPercentage = Convert.ToDecimal(gRow.Cells[1].Text);
                decimal allocatedDailyHour  = Convert.ToDecimal(System.Web.Configuration.WebConfigurationManager.AppSettings["LeaveHour"]);
                decimal distributedHour     = (allocatedDailyHour * allocatedPercentage) / 100;
                distributedHour = Math.Truncate(distributedHour * 1000) / 1000;

                decimal dtVal = 0;

                if (fTRow.Length > 0)
                {
                    dtVal = fTRow[0]["VHour"].ToString() == "" ? 0 : Convert.ToDecimal(fTRow[0]["VHour"].ToString().Trim());
                    dtVal = Math.Truncate(dtVal * 1000) / 1000;

                    gRow.Cells[i + 3].Text = dtVal.ToString().Trim();
                }
                else
                {
                }

                if (gRow.Cells[i + 3].Text != distributedHour.ToString())
                {
                    gRow.Cells[i + 3].BackColor = System.Drawing.ColorTranslator.FromHtml("#FFA500");
                }


                foreach (DataRow dRow in dtHolidays.Rows)
                {
                    holiDay = Convert.ToDateTime(dRow["HoliDate"].ToString().Trim());
                    if (holiDay == dtVDate)
                    {
                        {
                            gRow.Cells[i + 3].BackColor = System.Drawing.ColorTranslator.FromHtml("#F2DBDB");
                            grTimeSheet.HeaderRow.Cells[i + 3].BackColor = System.Drawing.ColorTranslator.FromHtml("#F2DBDB");
                        }
                    }
                }


                if (weekEndDay == "Y")
                {
                    gRow.Cells[i + 3].BackColor = System.Drawing.ColorTranslator.FromHtml("#B8CCE4");
                    grTimeSheet.HeaderRow.Cells[i + 3].BackColor = System.Drawing.ColorTranslator.FromHtml("#B8CCE4");
                }
            }
        }
    }