protected void ProductsCart_OnItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "Remove") { List <BLProduct> productsCart = (List <BLProduct>)Session["productsCart"]; int DeleteIndex = e.Item.ItemIndex; productsCart.RemoveAt(DeleteIndex); int[] amounts = (int[])Session["productAmount"]; //update num of products int numOfProducts = (int)Session["numOfProducts"]; Session["numOfProducts"] = numOfProducts - 1; //update amounts arr BLProduct.Delete(amounts, DeleteIndex); Session["productAmount"] = amounts; Update(productsCart); OrderNow.Visible = productsCart?.Count > 0; } }