// Delete a record protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Get the ID of the record to be deleted string id = grid.DataKeys[e.RowIndex].Value.ToString(); // Execute the delete command bool success = CatalogBLO.DeleteCategory(id); // Cancel edit mode grid.EditIndex = -1; // Display status message statusLabel.Text = success ? "Delete successful" : "Delete failed"; // Reload the grid BindGrid(); }