private void PostPageChanges2()
        {
            if (cbxEndSave.Checked)
            {
                int? month = null;
                int? day = null;
                int? year = null;

                int? month2 = null;
                int? day2 = null;
                int? year2 = null;

                if (tkrdpFrom.SelectedDate.HasValue)
                {
                    month = tkrdpFrom.SelectedDate.Value.Month;
                    day = tkrdpFrom.SelectedDate.Value.Day;
                    year = tkrdpFrom.SelectedDate.Value.Year;
                }

                if (tkrdpTo.SelectedDate.HasValue)
                {
                    month2 = tkrdpTo.SelectedDate.Value.Month;
                    day2 = tkrdpTo.SelectedDate.Value.Day;
                    year2 = tkrdpTo.SelectedDate.Value.Year;
                }

                if (rbtnEndSaveNew.Checked)
                {
                    if (tbxEndSaveNew.Text != "")
                    {
                        ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS);
                        projectCostingSheetTemplateInformation.Insert(tbxEndSaveNew.Text, cbxRehabAssessmentData.Checked, cbxFullLengthLiningData.Checked, cbxPointRepairData.Checked, cbxJunctionLiningData.Checked, cbxManholeRehabData.Checked, cbxMobilizationData.Checked, cbxOtherData.Checked, cbxLabourHour.Checked, cbxTrucksEquipment.Checked, cbxMaterial.Checked, cbxSubcontractor.Checked, cbxOtherCost.Checked, cbxRevenueInformation.Checked, false, Convert.ToInt32(hdfCompanyId.Value), month, day, year, month2, day2, year2);
                    }
                }

                if (rbtnEndSaveReplace.Checked)
                {
                    if (luEndSaveTemplate.SelectedIndex > 0)
                    {
                        ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS);
                        projectCostingSheetTemplateInformation.Update(Convert.ToInt32(luEndSaveTemplate.SelectedValue), luEndSaveTemplate.SelectedItem.Text, cbxRehabAssessmentData.Checked, cbxFullLengthLiningData.Checked, cbxPointRepairData.Checked, cbxJunctionLiningData.Checked, cbxManholeRehabData.Checked, cbxMobilizationData.Checked, cbxOtherData.Checked, cbxLabourHour.Checked, cbxTrucksEquipment.Checked, cbxMaterial.Checked, cbxSubcontractor.Checked, cbxOtherCost.Checked, cbxRevenueInformation.Checked, false, Convert.ToInt32(hdfCompanyId.Value), month, day, year, month2, day2, year2);
                    }
                }

                Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS;
                templateInformation = projectCostingSheetAddTDS.TemplateInformation;
                Session["templateInformation"] = templateInformation;
            }
        }
        protected void SaveSelectedId()
        {
            int idForUpdate = 0;
            bool selected = false;
            hdfSelectedIdTemplate.Value = "0";

            ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS);

            foreach (GridViewRow row in grdTemplate.Rows)
            {
                // ... Update all rows
                selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                idForUpdate = Int32.Parse(((Label)row.FindControl("lblCostingSheetTemplateID")).Text.Trim());
                projectCostingSheetTemplateInformation.Update(idForUpdate, selected);

                // ... Save selected project
                if (selected)
                {
                    hdfSelectedIdTemplate.Value = idForUpdate.ToString();
                }
            }

            projectCostingSheetTemplateInformation.Data.AcceptChanges();

            // Store datasets
            Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS;
            templateInformation = projectCostingSheetAddTDS.TemplateInformation;
            Session["templateInformation"] = templateInformation;
        }