Click here to Skip to main content
15,908,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a homework about online shop using ASP.net .
I must use sessions to store the items from page to page,that items have stored in gridview that taking its values from sql database.

How can I store in session the values in gridview. where the customer will choose ??

Thanks in Advance.
Zina
Posted
Updated 19-May-11 2:53am
v2

Hi Zina,

Its easy i did it some time when i start exploring .net
Check out this link
http://en.csharp-online.net/ASP.NET_State_Management%E2%80%94Session_State[^]

Let me know if you find any difficulty

Enjoy Life :)
 
Share this answer
 
This sounds like a good candidate for using a Shopping Basket

Generic Shopping Basket[^]

You should also think about creating a Product object, containing fields that describe the items that you will be selling in your online shop.

Populate the product objects from your SQL database and display them to the user in a grid or whatever. If a user chooses to purchase an item, you add it to the Shopping Basket. The Basket remembers items in the session between page redirects & you can always display a 'basket' area on your web page with the users current selection.

When they are finished browsing, you direct them to a Checkout page where you process the items in the Shopping Basket.

This is a pretty standard approach in e-commerce web apps & definitely one you should consider.

Have a google for 'ASP.Net Shopping Basket' for more examples
 
Share this answer
 
Create a class for storing the gridview items
means each gridview column is stored as a property in Class
class1 c=new class1();
c.name="Name";//Your gridview column value
c.Age="Age";//"
Then add the object to session variable
eg:
session[oSession"]=c;


You can access the session variable at any page...
 
Share this answer
 

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