private void Page_Load(object sender, System.EventArgs e) { try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if (Request.QueryString["id"] == null || Request.QueryString["catid"] == null) { Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { InspectionId = Convert.ToInt32(Request.QueryString["id"]); CategoryId = Convert.ToInt32(Request.QueryString["catid"]); } catch (FormatException fex) { Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } sLastPage = "admin_inspections_items.aspx?id=" + InspectionId.ToString(); sCurrentPage = "admin_inspection_category_edit.aspx?id=" + InspectionId.ToString() + "&catid=" + CategoryId.ToString(); this.PageTitle = "Inspection Category Edit"; Header.MainMenuSelectedItem = "Administration"; Header.AddJavaScriptFile("/admin_inspection_category_edit.js"); Header.AddBreadCrumb("Home", "/selectMode.aspx"); Header.AddBreadCrumb("Administration", "/admin.aspx"); Header.AddBreadCrumb("Inspections Manager", "/admin_inspections.aspx"); Header.AddBreadCrumb("Inspection Items Manager", "/" + sLastPage); Header.LeftBarHtml = "Add/Edit/Delete Inspection Category and Set Category Position and Items Position"; SaveCancelControl.CancelText = " Back "; SaveCancelControl.ParentPageURL = sLastPage; if (!IsPostBack) { inspect = new clsInspections(); inspect.cAction = "S"; inspect.iOrgId = OrgId; inspect.iId = InspectionId; inspect.iCategoryId = CategoryId; if (inspect.InspectCatDetails() == -1) { Session["lastpage"] = sLastPage; Session["error"] = _functions.ErrorMessage(156); Response.Redirect("error.aspx", false); return; } lblInspectionName.Text = inspect.sInspectionName.Value; tbCategory.Text = inspect.sCategoryName.Value; for (int i = 1; i <= inspect.iCatMaxPosition.Value; i++) { ddlOrder.Items.Add(new ListItem(i.ToString(), i.ToString())); } ddlOrder.SelectedValue = inspect.iCatPosition.Value.ToString(); dgInspectItems.DataSource = new DataView(inspect.GetInspectionItemsListByCategory()); dgInspectItems.DataBind(); if (dgInspectItems.Items.Count > 0 || CategoryId == 0) { btnDelete.Enabled = false; } } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = sLastPage; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (inspect != null) { inspect.Dispose(); } } }