/// <summary> /// Updates the quantities. /// </summary> private void UpdateQuantities() { int index = 0; foreach (LineItem item in CartHelper.LineItems) { EntryQuantityControl qtyBox = ShoppingCart.Rows[index].FindControl("Quantity") as EntryQuantityControl; decimal newQty; if (qtyBox.Quantity == null) { continue; } newQty = (decimal)qtyBox.Quantity; if (newQty <= 0) // remove { item.Delete(); } else if (newQty != item.Quantity) // update { item.Quantity = newQty; } index++; } CartHelper.RunWorkflow("CartValidate"); CartHelper.Cart.AcceptChanges(); }
/// <summary> /// Handles the RowCreated event of the ShoppingCart control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param> protected void ShoppingCart_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { EntryQuantityControl qtyBox = e.Row.FindControl("Quantity") as EntryQuantityControl; if (qtyBox != null) { if (e.Row.DataItem != null) { LineItem li = (LineItem)e.Row.DataItem; qtyBox.Quantity = li.Quantity; qtyBox.DataBind(); } } LinkButton linkButton = e.Row.FindControl("MoveWishList") as LinkButton; if (linkButton != null) { if (e.Row.DataItem != null) { linkButton.Visible = !((LineItem)e.Row.DataItem).CatalogEntryId.StartsWith("@"); } } } }