Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


iam doing sample project in online shopping. how to display add to cart count in masterpage.


i hope reply to me answer


thanks and regards
sravan
Posted

if you collecting in orders product id the session, and seprate in ID whit ',' and then set the text of a label in master page code behind:
C#
lblcount.Text = Session["orderID"].ToString().Split(',').Count();

there are too many ways to solve your problem but you have to say what is your logic to collecting users orders.
 
Share this answer
 
Comments
M.Sravan Kumar 4-Jun-12 6:09am    
if when i select the product and add to add to cart then display the count in masterpage and remove the product also count will be decrease in masterpage .


thanks and regards
sravan
 
Share this answer
 
Update the Session value when you add/remove items to/from cart & show the value on cart, that's all.

Add Items
C#
private void AddItemsToCart()
{
//Code to be written
//blah blah blah
Session["Item"] = ItemCount;
}

Remove Items
C#
private void RemoveItemsFromCart()
{
//Code to be written
//blah blah blah
Session["Item"] = ItemCount;
}

Display the value on Cart Label
C#
lblItemCount.Text = Session["Item"].ToString();
 
Share this answer
 
Comments
M.Sravan Kumar 5-Jun-12 5:18am    
thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900