Example #1
0
    protected void gvCart_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        /* Get the cart */
        /*ArrayList cart = (ArrayList)Session["Crat"];*/
        eStore.cart myCart = new eStore.cart();

        // get the current item to use it later
        eStore.cartItem currentItem = myCart.GetCartItem(e.RowIndex);

        /* make sure the cart exists in memory */
        //if (cart == null)
        //    cart = new ArrayList();

        /* check that the current index is available to be removed */
        //if (cart[e.RowIndex] != null)
        //    cart.RemoveAt(e.RowIndex);
        myCart.Remove(e.RowIndex);

        /* refresh the gridview so that it shows the changes */
        //gvCart.DataSource = myCart.cartItems;
        //gvCart.DataBind();
        myCart.BindToGrid(ref gvCart);

        /* save the cart */
        //Session["Crat"] = cart;
        myCart.Save();

        /* indicate success */
        lblOutput.Text = String.Format("The item {0} has been removed.", currentItem.product.name);
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        /* Step 1 - Get the cart */
        // ArrayList cart = (ArrayList)Session["Cart"];
        eStore.cart myCart = new eStore.cart();

        /* Step 2 - make sure it is actually a cart */

        /* handled by the cart constructor
         * if (cart == null)
         *  cart = new ArrayList();
         * */

        /* Step 3 - tell out cart display object (aka gvCart) what items are in our cart */
        //gvCart.DataSource = myCart.cartItems;

        /* Step 4 - bind the items to the cart (aka make them display) */
        //gvCart.DataBind();
        myCart.BindToGrid(ref gvCart);
    }