protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e) { DataSet cardsDS = (DataSet)Cache["Cards"]; int cardId = int.Parse(magicCardsGridView.Rows[e.RowIndex].Cells[0].Text); DataRow row = cardsDS.Tables["AllMagicCards"].Rows.Find(cardId); bool cardInDeck = new DecksService().cardAlreadyInDeck(cardId); bool userAddedCard = new UserCardService().userAlreadyAddedCard(cardId); if (!cardInDeck && !userAddedCard) { if (cardsService.DeleteRow(cardId) > 0) { row.Delete(); } else { Response.Write("<script>alert('Error Deleting');</script>"); } } else { cardsService.UnAbleCard(cardId); } magicCardsGridView.EditIndex = -1; magicCardsGridView.DataSource = (DataSet)Cache["Cards"]; magicCardsGridView.DataBind(); }