private void DeleteTemplate(int teamProjectTimeId)
        {
            // Create TDS to save
            teamProjectTime2TDSToSave = new TeamProjectTime2TDS();

            // Delete Template
            TeamProjectTime2Template teamProjectTime2Template = new TeamProjectTime2Template(teamProjectTime2TDS);
            teamProjectTime2Template.Delete(teamProjectTimeId);

            // ... Store datasets for teplate
            Session.Remove("templateDummy");
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
            template = teamProjectTime2TDS.Template;
            Session["template"] = teamProjectTime2TDS.Template;

            // Delete associated TeamProjectTime to Template
            // ... load TeamProjectTime
            TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave);
            teamProjectTime2Gateway.LoadByTeamProjectTimeId(teamProjectTimeId);

            // ... delete TeamProjectTime
            TeamProjectTime2 teamProjectTime2 = new TeamProjectTime2(teamProjectTime2TDSToSave);
            teamProjectTime2.Delete(teamProjectTimeId);

            // Delete associated TeamProjectTimeDetails to Template
            // ... load TeamProjectTimeDetails
            TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(teamProjectTime2TDSToSave);
            teamProjectTime2DetailGateway.LoadByTeamProjectTimeId(teamProjectTimeId);

            // ... delete TeamProjectTimeDetails
            TeamProjectTime2Detail teamProjectTime2Detail = new TeamProjectTime2Detail(teamProjectTime2TDSToSave);
            teamProjectTime2Detail.Delete(teamProjectTimeId);
        }
        protected void SaveSelectedId()
        {
            int idForUpdate = 0;
            bool selected = false;
            hdfSelectedIdTemplate.Value = "0";

            TeamProjectTime2Template teamProjectTime2Template = new TeamProjectTime2Template(teamProjectTime2TDS);

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

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

            // Store datasets
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
            template = teamProjectTime2TDS.Template;
            Session["template"] = teamProjectTime2TDS.Template;
        }