//Delte individual item by row deleting protected void detailGrid_Delete(object sender, GridViewDeleteEventArgs e) { GridViewRow row = GridViewForDetail.Rows[e.RowIndex]; string aa = Request.QueryString["ReqNo"]; int requisitionNo = int.Parse(aa); string item = (row.FindControl("ItemNO") as Label).Text; if (GridViewForDetail.Rows.Count == 0) { } else { //Delete row EmployeeController.DeleteForDetail(requisitionNo, item); //show back gridview reqhistory = new List <Detail>(); List <RequisitionDetail> reqHistory = EmployeeController.ViewRequisitionDetail(requisitionNo); foreach (RequisitionDetail r in reqHistory) { Detail d = new Detail(); d.itemNo = r.ItemNo; d.reqNo = r.ReqNo; d.quantity = r.Qty; d.description = r.StationeryItem.Description; reqhistory.Add(d); } GridViewForDetail.DataSource = reqhistory; GridViewForDetail.DataBind(); } }
//Data Bind Method for main page load private void BindGrid() { reqhistory = new List <Detail>(); List <RequisitionDetail> reqHistory = EmployeeController.ViewRequisitionDetail(reqNo); foreach (RequisitionDetail r in reqHistory) { Detail d = new Detail(); d.itemNo = r.ItemNo; d.reqNo = r.ReqNo; d.quantity = r.Qty; d.description = r.StationeryItem.Description; d.isEditable = r.RequisitionInfo.Status.Equals("Pending"); reqhistory.Add(d); } GridViewForDetail.DataSource = reqhistory; GridViewForDetail.DataBind(); }