protected void grdSupAtt_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            int FixCellCount = 3;
            int DayCount     = 0;
            //e.Row.Cells[0].Visible = false;

            if (e.Row.RowType == DataControlRowType.Header)
            {
                TableHeaderCell thc = new TableHeaderCell();
                thc.Attributes.Add("SR.NO.", "SR.NO.");
                thc.Text = "Sr.No.";
                e.Row.Cells.AddAt(0, thc);
                e.Row.Cells[2].Visible = false;
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TableCell tc = new TableCell();
                tc.Attributes.Add("SR.NO.", "SR.NO.");
                tc.Text            = Convert.ToString(e.Row.RowIndex + 1);
                tc.HorizontalAlign = HorizontalAlign.Center;
                e.Row.Cells.AddAt(0, tc);
                for (int i = 0; i < FixCellCount; i++)
                {
                    e.Row.Cells[i].CssClass = "Fixed";
                    //e.Row.Cells[i].Attributes.Add("onclick", "window.open('../Crew/CrewDetails.aspx?ID=" + CrewID + "');");
                }
                e.Row.Cells[2].Visible = false;

                e.Row.Cells[1].Width = 800;

                DateTime CurDateNew  = Convert.ToDateTime(Convert.ToString(1) + "/" + ViewState["CurrentMonth"].ToString() + "/" + ViewState["CurrentYear"].ToString());
                DateTime PreDateNew1 = CurDateNew.AddMonths(-1);
                for (int i = 0; i < DateTime.DaysInMonth(PreDateNew1.Year, PreDateNew1.Month); i++)
                {
                    // DateTime CurDateNew = Convert.ToDateTime(Convert.ToString(i - 1) + "/" + ViewState["CurrentMonth"].ToString() + "/" + ViewState["CurrentYear"].ToString());
                    DateTime PreDate = PreDateNew1.AddDays(i);
                    if (e.Row.Cells[2].Text != "&nbsp;")
                    {
                        DataTable dtPrvMonthSch = objInsp.TEC_Get_SupInspectionDetailsByDate(PreDate, Convert.ToInt32(e.Row.Cells[2].Text), UDFLib.ConvertToInteger(DDLCompany.SelectedValue));

                        if (dtPrvMonthSch.Rows.Count > 0)
                        {
                            // if (dtPrvMonthSch.Rows[0]["ActualDate"].ToString() == "")
                            {
                                int startDay = Convert.ToDateTime(dtPrvMonthSch.Rows[0]["StartDate"].ToString()).Day;
                                //int endDay = Convert.ToDateTime(dtPrvMonthSch.Rows[0]["EndDate"].ToString()).Day;
                                //double diff = (Convert.ToDateTime(dtPrvMonthSch.Rows[0]["EndDate"].ToString()) - Convert.ToDateTime(dtPrvMonthSch.Rows[0]["StartDate"].ToString())).TotalDays;
                                int    endDay = 0;
                                double diff   = 0;
                                if (dtPrvMonthSch.Rows[0]["EndDate"].ToString() != "")
                                {
                                    endDay = Convert.ToDateTime(dtPrvMonthSch.Rows[0]["EndDate"].ToString()).Day;
                                    diff   = (Convert.ToDateTime(dtPrvMonthSch.Rows[0]["EndDate"].ToString()) - Convert.ToDateTime(dtPrvMonthSch.Rows[0]["StartDate"].ToString())).TotalDays;
                                }


                                if ((startDay + Convert.ToInt32(diff)) > DateTime.DaysInMonth(PreDate.Year, PreDate.Month))
                                {
                                    int EndDay = (startDay + Convert.ToInt32(diff)) - DateTime.DaysInMonth(PreDate.Year, PreDate.Month);
                                    int StDay  = 1;
                                    e.Row.Cells[StDay + 2].Text = dtPrvMonthSch.Rows[0]["LocName"].ToString();
                                    e.Row.Cells[StDay + 2].Attributes["ColSpan"] = ((EndDay)).ToString();
                                    e.Row.Cells[StDay + 2].CssClass = "CurrentNew";
                                    e.Row.Cells[1].Font.Bold        = true;
                                    //for (int j = StDay + 1; j <= (StDay + EndDay); j++)
                                    //{
                                    //    if (j <= e.Row.Cells.Count - 2)
                                    //    {
                                    //        e.Row.Cells[j + 1].CssClass = "CurrentNew";
                                    //    }
                                    //}
                                    for (int j = StDay + 2; j <= (StDay + EndDay); j++)
                                    {
                                        if (j <= e.Row.Cells.Count - 2)
                                        {
                                            e.Row.Cells[j + 1].Visible = false;
                                            e.Row.Cells[j + 1].Controls.Clear();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                for (int i = FixCellCount; i < e.Row.Cells.Count; i++)
                {
                    DayCount++;
                    e.Row.Cells[i].Width = 80;
                    DateTime CurDate1 = Convert.ToDateTime(Convert.ToString(i - 2) + "/" + ViewState["CurrentMonth"].ToString() + "/" + ViewState["CurrentYear"].ToString());
                    if (CurDate1.DayOfWeek.ToString() == "Sunday" || CurDate1.DayOfWeek.ToString() == "Saturday")
                    {
                        if (e.Row.Cells[i].Text == "&nbsp;" || e.Row.Cells[i].Text == "")
                        {
                            e.Row.Cells[i].BackColor = ColorTranslator.FromHtml("#81BEF7");
                        }
                    }
                    if (e.Row.Cells[i].Text != "&nbsp;" && e.Row.Cells[i].Text != "")
                    {
                        DateTime CurDate = Convert.ToDateTime(Convert.ToString(i - 2) + "/" + ViewState["CurrentMonth"].ToString() + "/" + ViewState["CurrentYear"].ToString());

                        if (e.Row.Cells[2].Text != "")
                        {
                            DataTable dtSch = objInsp.TEC_Get_SupInspectionDetailsByDate(CurDate, Convert.ToInt32(e.Row.Cells[2].Text), UDFLib.ConvertToInteger(DDLCompany.SelectedValue));

                            if (dtSch.Rows.Count > 0)
                            {
                                int    startDay = Convert.ToDateTime(dtSch.Rows[0]["StartDate"].ToString()).Day;
                                int    endDay   = 0;
                                double diff     = 0;
                                //int endDay = Convert.ToDateTime(dtSch.Rows[0]["EndDate"].ToString()).Day;
                                //double diff = (Convert.ToDateTime(dtSch.Rows[0]["EndDate"].ToString()) - Convert.ToDateTime(dtSch.Rows[0]["StartDate"].ToString())).TotalDays;
                                if (dtSch.Rows[0]["EndDate"].ToString() != "")
                                {
                                    endDay = Convert.ToDateTime(dtSch.Rows[0]["EndDate"].ToString()).Day;
                                    diff   = (Convert.ToDateTime(dtSch.Rows[0]["EndDate"].ToString()) - Convert.ToDateTime(dtSch.Rows[0]["StartDate"].ToString())).TotalDays;
                                }

                                if ((startDay + Convert.ToInt32(diff)) > DateTime.DaysInMonth(CurDate.Year, CurDate.Month))
                                {
                                    int EndDay = (startDay + Convert.ToInt32(diff)) - DateTime.DaysInMonth(CurDate.Year, CurDate.Month);
                                    e.Row.Cells[startDay + 2].Text = dtSch.Rows[0]["LocName"].ToString();
                                    e.Row.Cells[startDay + 2].Attributes["ColSpan"] = ((Convert.ToInt32(diff) - EndDay) + 1).ToString();
                                    e.Row.Cells[startDay + 2].CssClass = "CurrentNew";
                                    e.Row.Cells[1].Font.Bold           = true;
                                    //for (int j = startDay + 1; j <= (startDay + (Convert.ToInt32(diff) - EndDay)) + 1; j++)
                                    //{
                                    //    if (j <= e.Row.Cells.Count -2)
                                    //    {
                                    //        e.Row.Cells[j + 1].CssClass = "CurrentNew";
                                    //    }
                                    //}
                                    for (int j = startDay + 2; j <= (startDay + (Convert.ToInt32(diff) - EndDay)) + 1; j++)
                                    {
                                        if (j <= e.Row.Cells.Count - 2)
                                        {
                                            e.Row.Cells[j + 1].Visible = false;
                                            e.Row.Cells[j + 1].Controls.Clear();
                                        }
                                    }
                                }
                                else
                                {
                                    e.Row.Cells[startDay + 2].Text = dtSch.Rows[0]["LocName"].ToString();
                                    e.Row.Cells[startDay + 2].Attributes["ColSpan"] = ((endDay - startDay) + 1).ToString();
                                    e.Row.Cells[startDay + 2].CssClass = "CurrentNew";
                                    e.Row.Cells[1].Font.Bold           = true;
                                    //for (int j = startDay + 1; j <= (startDay + diff) + 1; j++)
                                    //{
                                    //    if (j < e.Row.Cells.Count - 2)
                                    //    {
                                    //        e.Row.Cells[j + 1].CssClass = "CurrentNew";
                                    //    }
                                    //}
                                    for (int j = startDay + 2; j <= (startDay + diff) + 1; j++)
                                    {
                                        if (j <= e.Row.Cells.Count - 2)
                                        {
                                            e.Row.Cells[j + 1].Visible = false;
                                            e.Row.Cells[j + 1].Controls.Clear();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                e.Row.Cells[1].Font.Size = 10;
                e.Row.Cells[1].Font.Name = "Tahoma";
                e.Row.Cells[0].Font.Size = 10;
                e.Row.Cells[0].Font.Name = "Tahoma";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }