protected void rptVariants_OnItemCommand(Object source, RepeaterCommandEventArgs e) { if (e.CommandName == "AddToCart" || e.CommandName == "AddToWishlist") { NumericTextBox txtQuantity = e.Item.FindControl("txtQuantity") as NumericTextBox; Label productVariantID = e.Item.FindControl("ProductVariantID") as Label; ProductAttributesControl ctrlProductAttributes = e.Item.FindControl("ctrlProductAttributes") as ProductAttributesControl; Label lblError = e.Item.FindControl("lblError") as Label; try { if (e.CommandName == "AddToCart") { List <string> addToCartWarnings = ShoppingCartManager.AddToCart(ShoppingCartTypeEnum.ShoppingCart, Convert.ToInt32(productVariantID.Text), ctrlProductAttributes.SelectedAttributes, txtQuantity.Value); if (addToCartWarnings.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } else { StringBuilder addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append("<br />"); } } lblError.Text = addToCartWarningsSb.ToString(); } } if (e.CommandName == "AddToWishlist") { List <string> addToCartWarnings = ShoppingCartManager.AddToCart(ShoppingCartTypeEnum.Wishlist, Convert.ToInt32(productVariantID.Text), ctrlProductAttributes.SelectedAttributes, txtQuantity.Value); if (addToCartWarnings.Count == 0) { Response.Redirect("~/Wishlist.aspx"); } else { StringBuilder addToCartWarningsSb = new StringBuilder(); for (int i = 0; i < addToCartWarnings.Count; i++) { addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i])); if (i != addToCartWarnings.Count - 1) { addToCartWarningsSb.Append("<br />"); } } lblError.Text = addToCartWarningsSb.ToString(); } } } catch (Exception exc) { LogManager.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc); lblError.Text = Server.HtmlEncode(exc.Message); } } }