protected void gvitem_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { DBOps db = new DBOps(); // GridViewRow gvr = (GridViewRow)(((Button)e.CommandSource).NamingContainer); int RowIndex = e.RowIndex; string item = gvitem.Rows[RowIndex].Cells[1].Text; string lab = gvitem.Rows[RowIndex].Cells[6].Text; int retval = db.DeleteInventoryTable(item, lab, "", ""); if (retval > 0) { lblPageInfo.Text = "Row deleted successfully."; lblPageInfo.DataBind(); } else { lblPageInfo.ForeColor = System.Drawing.Color.Red; lblPageInfo.Text = "An error occurred while attempting to delete the row."; lblPageInfo.DataBind(); //lblPageInfo.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0099ff"); //original blue color } } catch (Exception ex) { throw ex; } RefreshTable(); }