private void BindGrid()
        {
            List <CartItem> cartItemList = CartItemModel.GetCartItems(username);

            GridView1.DataSource = cartItemList;
            GridView1.DataBind();
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int cartItemId = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);

            CartItemModel.RemoveFromCart(cartItemId);
            BindGrid();
            TotalAmountLabel.Text = string.Format("{0:C}", TotalPrice(CartItemModel.GetCartItems(username)));
        }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Label2.Text = DateTime.Now.ToString();
     if (!IsPostBack)
     {
         string username = Session[Constants.USER_ID].ToString();
         GridView1.DataSource = CartItemModel.GetCartItems(username);
         GridView1.DataBind();
         List <UserDetail> user = new List <UserDetail>();
         user.Add(UserDetailModel.GetUserByUserName(username));
         DetailsView1.DataSource = user;
         DetailsView1.DataBind();
     }
 }
 protected void RefreshButton_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in GridView1.Rows)
     {
         if (row.RowType == DataControlRowType.DataRow)
         {
             TextBox textBox     = row.FindControl("TextBox1") as TextBox;
             int     newQuantity = Convert.ToInt32(textBox.Text);
             int     cartItemId  = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Values[0]);
             CartItemModel.UpdateCartItemQuantity(cartItemId, newQuantity);
         }
     }
     BindGrid();
     TotalAmountLabel.Text = string.Format("{0:C}", TotalPrice(CartItemModel.GetCartItems(username)));
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     username = Session[Constants.USER_ID].ToString();
     BindGrid();
     TotalAmountLabel.Text = string.Format("{0:C}", TotalPrice(CartItemModel.GetCartItems(username)));
 }