By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

shopping cart concept

P: n/a
Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart
concept on my application? When the user clicks add item, it will be stored
on some storage format, I dont know what is the term: temp/global DataSet,
etc... and it should be read on other web-form to checkout the items...

Can you point me to the right direction?

Thank you very much!
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Paulo" <er********@terra.com.brwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart
concept on my application? When the user clicks add item, it will be
stored on some storage format, I dont know what is the term: temp/global
DataSet, etc... and it should be read on other web-form to checkout the
items...
Basically, you have several choices depending on how you've designed your
web app, and what resources you have at your disposal...

As you've discovered, the information in the shopping cart needs to be
persisted (i.e. "remembered") across multiple pages. Therefore, you can't
use ViewState. However, it's vital that different concurrent users don't get
their shopping carts mixed up, so you can't use the Application object
either.

Does your web app use a back-end database? If so, then you can use that to
store the shopping cart. This will also have the advantage that users could
"save" their cart and come back to it later. Some people like to offer this
facility...

Alternatively, even if your web app does use a database, you might prefer to
persist the cart information in the Session object. This is very simple to
do. Obviously, if you use the Session object, then any information stored in
it will be lost when the Session ends either because the user has logged out
and you've torn down the Session in code, or because it has timed out...

A third alternative would be to store the cart data in a cookie. However,
this would obviously not work if the user has disabled cookies in their
browser - some users do this for (supposed) security reasons.

Personally, I use the Session object for shopping cart. I use a
Dictionary<int, intgeneric for this. The Dictionary is keyed on the
product's unique identifier, and the value is the number of items purchased.
This has the advantage of keeping the object persisted in Session as small
as possible.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2

P: n/a
Mark, what do you think about this solution? Good or bad?

http://www.sitepoint.com/article/net...art-datatables

Thank you very much!

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netescreveu na mensagem
news:e6**************@TK2MSFTNGP02.phx.gbl...
"Paulo" <er********@terra.com.brwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart
concept on my application? When the user clicks add item, it will be
stored on some storage format, I dont know what is the term: temp/global
DataSet, etc... and it should be read on other web-form to checkout the
items...

Basically, you have several choices depending on how you've designed your
web app, and what resources you have at your disposal...

As you've discovered, the information in the shopping cart needs to be
persisted (i.e. "remembered") across multiple pages. Therefore, you can't
use ViewState. However, it's vital that different concurrent users don't
get their shopping carts mixed up, so you can't use the Application object
either.

Does your web app use a back-end database? If so, then you can use that to
store the shopping cart. This will also have the advantage that users
could "save" their cart and come back to it later. Some people like to
offer this facility...

Alternatively, even if your web app does use a database, you might prefer
to persist the cart information in the Session object. This is very simple
to do. Obviously, if you use the Session object, then any information
stored in it will be lost when the Session ends either because the user
has logged out and you've torn down the Session in code, or because it has
timed out...

A third alternative would be to store the cart data in a cookie. However,
this would obviously not work if the user has disabled cookies in their
browser - some users do this for (supposed) security reasons.

Personally, I use the Session object for shopping cart. I use a
Dictionary<int, intgeneric for this. The Dictionary is keyed on the
product's unique identifier, and the value is the number of items
purchased. This has the advantage of keeping the object persisted in
Session as small as possible.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3

P: n/a
"Paulo" <er********@terra.com.brwrote in message
news:uQ**************@TK2MSFTNGP04.phx.gbl...

[top-posting corrected]
>Personally, I use the Session object for shopping cart. I use a
Dictionary<int, intgeneric for this. The Dictionary is keyed on the
product's unique identifier, and the value is the number of items
purchased. This has the advantage of keeping the object persisted in
Session as small as possible.

Mark, what do you think about this solution? Good or bad?

http://www.sitepoint.com/article/net...art-datatables
I'm sure it will work...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.