private void RefreshGridView() { BLL.Cart c = new BLL.Cart(); cList = c.GetAllCartP(); GvCart.Visible = true; GvCart.DataSource = cList; GvCart.DataBind(); }
private void RefreshGridView() { CartDetails c = new CartDetails(); cList = c.GetAllCartP(Session["userName"].ToString()); GvCart.Visible = true; GvCart.DataSource = cList; GvCart.DataBind(); }
public void refresh() { List <item> mycart = (List <item>)(HttpContext.Current.Session["myCart"]); //If cart is not empty if (mycart != null) { //add cart items to gridview DataTable dt = new DataTable(); dt.Columns.Add("ProductID", System.Type.GetType("System.Int32")); dt.Columns.Add("Name", System.Type.GetType("System.String")); dt.Columns.Add("Price", System.Type.GetType("System.Int32")); dt.Columns.Add("Quantity", System.Type.GetType("System.Int32")); double total = 0.0; foreach (item j in mycart) { try { total += (j.Quantity * j.Price); } catch { } dt.Rows.Add(j.Num, j.Name, j.Price, j.Quantity); } LblTotal.Text = total.ToString(); //bind cart to datatable GvCart.DataSource = dt; GvCart.DataBind(); if (mycart.Count == 0) { LnkCheckout.Visible = false; } else { LnkCheckout.Visible = true; } } else { LnkCheckout.Visible = false; } }