protected void requisitionItemListGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "edit") { } else if (e.CommandName == "delete") { int reqItemID = Int32.Parse(e.CommandArgument.ToString());// reqitemID !!! not ItemID!!!! List <ReqItems_custom> lri = new List <ReqItems_custom>(); lri = this.lr_temp; for (int i = lri.Count - 1; i >= 0; i--) { if (lri[i].ReqItemID == reqItemID) { lri.RemoveAt(i); } } this.lr_temp = lri; if (lri.Count == 0)//IF deleting the last reqItem,DELETE this req { RequisitionDAO rdao = new RequisitionDAO(); rdao.removeRequisition(this.reqID); Response.Redirect("Emp_MyRequisition.aspx"); } RequisitionItemDAO ridao = new RequisitionItemDAO(); ridao.removeItemByReqItemID(reqItemID); requisitionItemListGridView.DataSource = lri; requisitionItemListGridView.DataBind(); } else if (e.CommandName == "Update") { this.reqItemID = Int32.Parse(e.CommandArgument.ToString()); } }
protected void requisitionListGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete") { string a = e.CommandArgument.ToString(); int req = Int32.Parse(e.CommandArgument.ToString()); RequisitionDAO rdao = new RequisitionDAO(); string name = Session["loginID"].ToString(); rdao.removeRequisition(req); this.lr = rdao.getRequisitionByStaffID(name); requisitionListGridView.DataSource = rdao.getReqByStaffIDandStatus(name, "pending"); requisitionListGridView.DataBind(); } }