Hi
This will help u lot if u have query plz let me know Dont forget that u must use genrices list for product so u can have n number of product in a single session
Cart should be Structured like as given below
CART
public class Cart
{
public List<Products> Products = new List<Products>();
public float TotalAmt;
public float TotalWeight;
public float ShippingCharge;
public float Tax;
public float TotalSum;
public int ShippingAddress;
public float SubTotal;
public float PaymentAmount;
}
PRODUCT
public class Products
{
private int _ProductId;
private string _ProductName;
private string _ShortDescription;
private string _LongDescription;
// List of Property
#region "Price attached for display in ProductLarge Page"
private float _Price;
private int _Quantity;
public int Quantity
{
get { return _Quantity; }
set { _Quantity = value; }
}
public float Price
{
get { return _Price; }
set { _Price = value; }
}
#endregion
public int ProductId
{
get { return _ProductId; }
set { _ProductId = value; }
}
public string ProductName
{
get { return _ProductName; }
set { _ProductName = value; }
}
public string ShortDescription
{
get { return _ShortDescription; }
set { _ShortDescription = value; }
}
public string LongDescription
{
get { return _LongDescription; }
set { _LongDescription = value; }
}
}
POPULATING
Session["Carts"] =(Cart)Session["Cart"];
if (Session["Carts"] != null)
{
objCart.TotalAmt = 0;
foreach (Products objProducts in objCart.Products)
{
objCart.TotalAmt += objProducts.Price * objProducts.Quantity;
}
string l_subtotal = string.Format("{0:f}", objCart.TotalAmt);
ltrSubTotal.Text = l_subtotal;
if (objCart.Products.Count != 0)
{
gvShoppingCart.DataSource = objCart.Products;
gvShoppingCart.DataBind();
}
}