Esempio n. 1
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to load the
        // ShoppingCart DataGrid *the first time* the page is
        // accessed.
        //
        // Note that subsequent postbacks to the page *do not*
        // reload the Datagrid.  Instead, we rely on the control's
        // built-in viewstate management to rebuild the control
        // on the server.
        //
        //*******************************************************
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (Page.IsPostBack == false) {

                // Calculate end-user's shopping cart ID
                AWC.BusinessLayer.ShoppingCart cart = new AWC.BusinessLayer.ShoppingCart();
                String cartId = cart.GetShoppingCartId();

                // Populate datagrid with shopping cart data
                MyDataGrid.DataSource = cart.GetItems(cartId);
                MyDataGrid.DataBind();

                // Update total price label
                TotalLbl.Text = String.Format( "{0:c}", cart.GetTotal(cartId));
            }
        }
        void PopulateShoppingCartList()
        {
            AWC.BusinessLayer.ShoppingCart cart = new AWC.BusinessLayer.ShoppingCart();

            // Obtain current user's shopping cart ID
            String cartId = cart.GetShoppingCartId();

            // If no items, hide details and display message
            if (cart.GetItemCount(cartId) == 0)
            {
                DetailsPanel.Visible = false;
                MyError.Text = "There are currently no items in your shopping cart.";
            }
            else
            {

                // Databind Gridcontrol with Shopping Cart Items
                MyList.DataSource = cart.GetItems(cartId);
                MyList.DataBind();

                //Update Total Price Label
                lblTotal.Text = String.Format("{0:c}", cart.GetTotal(cartId));
            }
        }