using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace AjaxCart
{
    public partial class _Default : System.Web.UI.Page
    {
        protected Decimal Total
        {
            get
            {
                object o = ViewState["Total"];
                if (o == null)
                    return 0;
                else
                    return (Decimal)o;
            }
            set
            {
                ViewState["Total"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            Page.DataBind();
        }

        protected void pbAdd_Click(object sender, EventArgs e)
        {
            int qty = Int32.Parse( tbQuantity.Text );
            Decimal price = Decimal.Parse( ddlItems.SelectedItem.Value );
            lbItemsInCart.Items.Add( new ListItem( String.Format( "{0} {1} at {2:c}", qty, ddlItems.SelectedItem.Text, price )));
            Total += qty * price;
            //tbQuantity.Text = "";
            //RadAjaxPanel1.FocusControl(tbQuantity);
        }
    }
}
