protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { // get the ID of the clicked row int ID = Convert.ToInt32(e.CommandArgument); // Delete the record FBFoodInventoryController controller = new FBFoodInventoryController(); controller.FBLineItems_Delete(ID); // DeleteRecordByID(ID); // Implement this on your own :) } if (e.CommandName == "Edit") { int ID = Convert.ToInt32(e.CommandArgument); FBFoodInventoryController controller = new FBFoodInventoryController(); FBFoodInventoryInfo item = controller.FBLineItems_GetByID(ID); if (item != null) { txtLineItemID_Edit.Value = item.LineItemID.ToString(); txtCasesAddNewEdit.Text = item.Cases.ToString(); txtCountPerCaseAddNewEdit.Text = item.CountPerCase.ToString(); txtWeightPerCaseAddNewEdit.Text = item.WeightPerCase.ToString(); txtPricePerCaseAddNewEdit.Text = item.PricePerCase.ToString(); ddlProducts.SelectedValue = item.ProductID.ToString(); if (item.ReportType != null) { ddlReportType.SelectedValue = item.ReportType.ToString(); } btnAdd.Text = "Update Item"; } else { txtLineItemID_Edit.Value = "0"; } } GroupIt(); GetLineItems(Int32.Parse(txtInvoiceID.Value.ToString())); }