private int PostPageChanges()
        {
            int numOfProjectTimesSelected = 0;

            // Clear the projectTimesIdSelected list
            Session.Remove("projectTimesIdSelected");

            bool selected = false;
            int projectTimeId = 0;
            int employeeId = 0;

            List<int> projectTimesIdSelected = new List<int>();

            ProjectTimeApprove projectTimeApprove = new ProjectTimeApprove(projectTimeApproveTDS);

            foreach (GridViewRow row in grdProjectTimeApprove.Rows)
            {
                // ... Update all rows
                selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                projectTimeId = Int32.Parse(((Label)row.FindControl("lblProjectTimeID")).Text.Trim());
                employeeId = Int32.Parse(((Label)row.FindControl("lblEmployeeID")).Text.Trim());

                projectTimeApprove.Update(projectTimeId, selected);

                // ... Save selecteds project times id
                if (selected)
                {
                    numOfProjectTimesSelected++;
                    projectTimesIdSelected.Add(projectTimeId);
                }
            }

            projectTimeApproveTDS.AcceptChanges();

            // ... Store datasets
            Session["projectTimeApproveTDS"] = projectTimeApproveTDS;
            Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove;

            // ... Store project times id list
            Session["projectTimesIdSelected"] = projectTimesIdSelected;

            return numOfProjectTimesSelected;
        }
        private void SetFocusGridView()
        {
            try
            {
                // ... Get row
                int index = (int)Session["projectTimeIdSelected"];
                GridViewRow gridRow = grdProjectTimeApprove.Rows[index];

                // ... Select row
                ProjectTimeApprove projectTimeApprove = new ProjectTimeApprove(projectTimeApproveTDS);
                int idForUpdate = Int32.Parse(((Label)gridRow.FindControl("lblProjectTimeID")).Text.Trim());
                projectTimeApprove.Update(idForUpdate, true);
                projectTimeApprove.Data.AcceptChanges();

                // ... Store datasets
                Session["projectTimeApproveTDS"] = projectTimeApproveTDS;
                Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove;
            }
            catch
            {
            }
        }
        protected int SaveSelectedId()
        {
            int numOfProjectTimesSelected = 0;
            int idForUpdate = 0;
            int employeeIdForUpdate = 0;
            bool selected = false;
            hdfSelectedProjectTimeId.Value = "0";

            ProjectTimeApprove projectTimeApprove = new ProjectTimeApprove(projectTimeApproveTDS);

            foreach (GridViewRow row in grdProjectTimeApprove.Rows)
            {
                // ... Update all rows
                selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                idForUpdate = Int32.Parse(((Label)row.FindControl("lblProjectTimeID")).Text.Trim());
                employeeIdForUpdate = Int32.Parse(((Label)row.FindControl("lblEmployeeID")).Text.Trim());

                projectTimeApprove.Update(idForUpdate, selected);

                // ... Save selected id
                if (selected)
                {
                    hdfSelectedProjectTimeId.Value = idForUpdate.ToString();
                    hdfSelectedEmployeeId.Value = employeeIdForUpdate.ToString();
                    DateTime date_ = DateTime.Parse(((Label)row.FindControl("lblDate")).Text.Trim());

                    PayPeriodGateway payPeriodGateway = new PayPeriodGateway(new DataSet());
                    hdfSelectedPeriodId.Value = payPeriodGateway.GetPayPeriodId(date_).ToString();

                    numOfProjectTimesSelected++;

                    Session["projectTimeIdSelected"] = row.RowIndex;
                }
            }

            projectTimeApprove.Data.AcceptChanges();

            // ... Store datasets
            Session["projectTimeApproveTDS"] = projectTimeApproveTDS;
            Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove;

            return numOfProjectTimesSelected;
        }