private void LateralsProcessGrid()
        {
            TeamProjectTime2SectionLateral model = new TeamProjectTime2SectionLateral(teamProjectTime2TDS);

            foreach (GridViewRow rowSections in grdSectionsReinstatePostVideo.Rows)
            {
                int totalSelected = 0;
                int totalBrushed = 0;
                int totalOpened = 0;

                string sectionIdReinstatePostVideo = ((Label)rowSections.FindControl("lblSectionID")).Text;

                bool selectedSection = ((CheckBox)rowSections.FindControl("cbxSelected")).Checked;

                if (selectedSection)
                {
                    foreach (GridViewRow row in grdLaterals.Rows)
                    {
                        string sectionId = ((Label)row.FindControl("lblSectionID")).Text;
                        if (sectionId != "")
                        {
                            if (sectionId == sectionIdReinstatePostVideo)
                            {
                                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                bool opened = ((CheckBox)row.FindControl("cbxOpened")).Checked;
                                bool brushed = ((CheckBox)row.FindControl("cbxBrushed")).Checked;
                                string lateralId = ((Label)row.FindControl("lblLateralID")).Text;

                                if (selected)
                                {
                                    totalSelected++;

                                    if (opened)
                                    {
                                        totalOpened++;
                                    }

                                    if (brushed)
                                    {
                                        totalBrushed++;
                                    }
                                }

                                model.Update(sectionId, lateralId, opened, brushed, selected);
                            }
                        }
                    }

                    if (totalSelected > 0)
                    {
                        if (totalOpened == totalSelected)
                        {
                            ((Label)rowSections.FindControl("lblPercentageOpened")).Text = "50";
                        }
                        else
                        {
                            double percentageOpened = ((double)totalOpened / (double)totalSelected) * 50;

                            if (percentageOpened >= 25)
                            {
                                ((Label)rowSections.FindControl("lblPercentageOpened")).Text = "25";
                            }
                            else
                            {
                                ((Label)rowSections.FindControl("lblPercentageOpened")).Text = "0";
                            }
                        }

                        if (totalBrushed == totalSelected)
                        {
                            ((Label)rowSections.FindControl("lblPercentageBrushed")).Text = "50";
                        }
                        else
                        {
                            double percentageBrushed = ((double)totalBrushed / (double)totalSelected) * 50;

                            if (percentageBrushed >= 25)
                            {
                                ((Label)rowSections.FindControl("lblPercentageBrushed")).Text = "25";
                            }
                            else
                            {
                                ((Label)rowSections.FindControl("lblPercentageBrushed")).Text = "0";
                            }
                        }

                        if ((totalOpened == totalSelected) && (totalBrushed == totalSelected))
                        {
                            ((CheckBox)rowSections.FindControl("cbxCompleted")).Checked = true;
                        }
                        else
                        {
                            ((CheckBox)rowSections.FindControl("cbxCompleted")).Checked = false;
                        }
                    }
                }
            }

            model.Table.AcceptChanges();

            teamProjectTimeSectionLateral = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTION_LATERALDataTable)model.Table;
            Session["teamProjectTimeSectionLateral"] = teamProjectTimeSectionLateral;
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
        }
        protected void cbxSelectedSectionReinstatePostVideo_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox checkbox = (CheckBox)sender;
            GridViewRow row = (GridViewRow)checkbox.NamingContainer;
            string sectionId = ((Label)row.FindControl("lblSectionID")).Text;
            TeamProjectTime2SectionLateral model = new TeamProjectTime2SectionLateral(teamProjectTime2TDS);

            if (sectionsReinstatePostVideoSelect == null)
            {
                sectionsReinstatePostVideoSelect = new ArrayList();
            }

            if (checkbox.Checked)
            {
                if (!sectionsReinstatePostVideoSelect.Contains(sectionId))
                {
                    LateralsProcessGrid();
                    model.Load(sectionId);
                    sectionsReinstatePostVideoSelect.Add(sectionId);
                }

                // Store tables
                teamProjectTimeSectionLateral = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTION_LATERALDataTable)model.Table;

                Session["teamProjectTimeSectionLateral"] = teamProjectTimeSectionLateral;
                Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                Session.Remove("teamProjectTimeSectionLateralDummy");

                grdLaterals.DataBind();

                upnlFullLengthReinstatePostVideo.Update();
            }
            else
            {
                if (sectionsReinstatePostVideoSelect.Contains(sectionId))
                {
                    sectionsReinstatePostVideoSelect.Remove(sectionId);

                    model.Delete(sectionId);

                    // Store tables
                    teamProjectTimeSectionLateral = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTION_LATERALDataTable)model.Table;

                    Session["teamProjectTimeSectionLateral"] = teamProjectTimeSectionLateral;
                    Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                    Session.Remove("teamProjectTimeSectionLateralDummy");

                    grdLaterals.DataBind();

                    upnlFullLengthReinstatePostVideo.Update();
                }
            }

            Session["sectionsReinstatePostVideoSelect"] = sectionsReinstatePostVideoSelect;
        }