protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Cart == null) { ShoppingCartPanel.Visible = false; ShoppingCartEmptyPanel.Visible = true; return; } var cartItems = Cart.GetCartItems().Select(sci => sci.Entity).ToArray(); if (!cartItems.Any()) { ShoppingCartPanel.Visible = false; ShoppingCartEmptyPanel.Visible = true; return; } ShoppingCartEmptyPanel.Visible = false; CartItems.DataSource = cartItems.Select(item => { var product = ServiceContext.CreateQuery("product").First(p => p.GetAttributeValue <Guid>("productid") == (item.GetAttributeValue <EntityReference>("adx_productid") == null ? Guid.Empty : item.GetAttributeValue <EntityReference>("adx_productid").Id)); return(new { Id = item.GetAttributeValue <Guid>("adx_shoppingcartitemid"), Description = product == null ? item.GetAttributeValue <string>("adx_name") : product.GetAttributeValue <string>("name"), Price = item.GetAttributeValue <Money>("adx_quotedprice") != null ? item.GetAttributeValue <Money>("adx_quotedprice").Value : 0, Quantity = item.GetAttributeValue <decimal?>("adx_quantity").GetValueOrDefault(1), Total = item.GetAttributeValue <decimal?>("adx_quantity").GetValueOrDefault(1) * (item.GetAttributeValue <Money>("adx_quotedprice") != null ? item.GetAttributeValue <Money>("adx_quotedprice").Value : 0), Url = GetProductUrl(product) }); }); CartItems.DataBind(); Total.Text = Cart.GetCartTotal().ToString("C2"); SaveToQuote.Visible = SaveToQuoteEnabled; }