Hi all,
I'm in the middle of building a small online shop using ASP.NET and VB.Net.
I have 3 pages:
Home,
Product Details and
Shopping Cart.
The
Home Page displays all products in a Grid View. When a user clicks on a product, he/she gets redirected to the
Product Details page. In this page, if the user clicks on the
Buy button, two things happen here:
1. an insert statement takes the Product ID and the GUID to the database
2. the user gets redirected to the
Shopping Cart page to view his/her items.
The problem is that when I go check the Basket table for the current session, the GUID is different in each row. I suppose to see something like this in the Basket table:
ProductID.......
GUID
1 ................... 6719c79a-2952-4615-8441-ecc06d7ecc77
2 ................... 6719c79a-2952-4615-8441-ecc06d7ecc77
3 ................... 6719c79a-2952-4615-8441-ecc06d7ecc77
The code behind might explain more, here is what I have written in the
Product Details page:
Page Load Event:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Session("guid") = Guid.NewGuid().ToString()
End If
End Sub
Button Click Event
Protected Sub Button3_Click(sender As Object, e As System.EventArgs)
Dim insert As New DataSet1TableAdapters.BasketTableAdapter
insert.InsertQuery(Me.Request.QueryString("ProductID"), Me.Session("guid"))
Response.Redirect("MyShoppingCart.aspx")
End Sub
My question is: how can I retain the same GUID for a user until he/she checkout or leave the website?
Please help me sorting this issue.
Finally, sorry for the weak language.