protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } //data loaded successfully try { dsEquipment = new EquipmentDataSet(); equipmentTableAdapter daEquipment = new equipmentTableAdapter(); daEquipment.Fill(dsEquipment.equipment); rows = (Session["criteria"] != null) ? dsEquipment.equipment.Select(Session["criteria"].ToString()) //has criteria : dsEquipment.equipment.Select(); //select all DisplayEquipment(); } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } try { dsEquipment = new EquipmentDataSet(); equipmentCRUDTableAdapter daEquipment = new equipmentCRUDTableAdapter(); daEquipment.Fill(dsEquipment.equipmentCRUD); if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page { id = Convert.ToInt32(Request.Cookies["ID"].Value); } if (Request.Cookies["Action"] != null && Request.Cookies["Action"].Value == "Delete") { pnlDeleteConfirm.Visible = true; lblTitle.Text = "Delete Equipment"; txtID.ReadOnly = true; txtModel.ReadOnly = true; txtSerialNum.ReadOnly = true; ddlCustomer.Enabled = false; ddlManufacturer.Enabled = false; ddlType.Enabled = false; divBtnEquipments.Visible = false; } else { pnlDeleteConfirm.Visible = false; } } catch { return; } if (!IsPostBack) { if (id != -1) { try { DataRow equipment = dsEquipment.equipmentCRUD.FindByID(id); // Find the related Record and fill the fields in the page with the data if (equipment != null) { this.txtID.Text = equipment.ItemArray[0].ToString(); this.txtModel.Text = equipment.ItemArray[1].ToString(); this.txtSerialNum.Text = equipment.ItemArray[2].ToString(); this.ddlCustomer.SelectedValue = equipment.ItemArray[3].ToString(); this.ddlType.SelectedValue = equipment.ItemArray[4].ToString(); this.ddlManufacturer.SelectedValue = equipment.ItemArray[5].ToString(); } else { lblStatus.Text = "Please Try Again"; } } catch { lblStatus.Text = "Database Error"; } } } }