private void Page_Load(object sender, System.EventArgs e)
        {
            OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
            if (Request.QueryString["id"] == null)
            {
                Session["lastpage"] = "admin_pmschedules.aspx";
                Session["error"]    = _functions.ErrorMessage(104);
                Response.Redirect("error.aspx", false);
                return;
            }
            try
            {
                PMSchedId = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch (FormatException fex)
            {
                Session["lastpage"] = "admin_pmschedules.aspx";
                Session["error"]    = _functions.ErrorMessage(105);
                Response.Redirect("error.aspx", false);
                return;
            }

            try
            {
                if (!IsPostBack)
                {
                    pmitems            = new clsPMSchedService();
                    pmitems.cAction    = "S";
                    pmitems.iOrgId     = OrgId;
                    pmitems.iPMSchedId = PMSchedId;
                    if (pmitems.PMScheduleDetails() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(169);
                        return;
                    }
                    lblPMScheduleName.Text     = pmitems.sPMSchedName.Value;
                    hlAddPMService.NavigateUrl = "admin_pmschedule_detail_edit.aspx?id=" + PMSchedId.ToString() + "&detailid=0";
                    lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='" + this.ParentPageURL + "'\">";
                    dgPMSchedDetails.DataSource = pmitems.GetPMServicesListForSchedule();
                    dgPMSchedDetails.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pmitems != null)
                {
                    pmitems.Dispose();
                }
            }
        }