protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; strProductID = grid.DataKeys[rowIndex]["ProductID"].ToString(); strProductSellerDetailID = grid.DataKeys[rowIndex]["ProductSellerDetailID"].ToString(); if (Int32.TryParse(strProductID, out intProductID) && Int32.TryParse(strProductSellerDetailID, out intProductSellerDetailID)) { try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { bool success = cart.ShoppingCart_RemoveItem(intProductID, intProductSellerDetailID); lblStatus.Text = success ? "<br />Product successfully removed!<br />" : "<br />There was an error removing the product!<br />"; } } catch (Exception ex) { lblSystemMessage.Text = "Error:" + ex.Message; } } PopulateControls(); }