public void RemoveCartItem(object sender, EventArgs e) { Button btn = (Button)sender; GridViewRow grRow = (GridViewRow)btn.NamingContainer; string rowID = grRow.UniqueID; string itemID = Request[rowID + "$cartItemID"]; string quantityString = Request[rowID + "$removedQuantity"]; int quantity; if (String.IsNullOrEmpty(itemID) || !Int32.TryParse(quantityString, out quantity)) { return; } ShoppingCartActions actions = new ShoppingCartActions(); actions.RemoveCartItem(itemID, quantity); Response.Redirect(Request.RawUrl); }