Session variables

SLG31

Member
Joined
Aug 18, 2007
Messages
5
Programming Experience
1-3
I'm designing like a shopping cart and have a product list which is an xml file consisting of products and prices which is loaded into a dataset then bound to a datagrid

There are buttons next to each product by clicking one of these should direct the user to another form showing the choice of product and price in textboxes, I can't load the info into the next form using session variables

My code is below

1st form code

VB.NET:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Set the path of XML file and schema
        Dim strPath As String = Server.MapPath(".")
        ' Declare a dataset
        Dim dsProducts As New DataSet
        ' Apply the XML schema to the dataset
        dsProducts.ReadXmlSchema(strPath & "\Products.xsd")
        ' Read the XML into the data set
        dsProducts.ReadXml(strPath & "\Products.xml")
        DataGrid1.DataSource = dsProducts
        DataGrid1.DataBind()
        Session("Products") = dsProducts.Tables(0)

    End Sub

Private Sub btnJam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJam.Click

        Response.Redirect("order.aspx")

    End Sub
As you can see I'm trying to create the session variables before the next form is loaded but unsure on the coding for this and for the next form which should load the session variables in the product and price textboxes

Any advice would be appreciated

Thanks
 
Last edited by a moderator:
Hm. Might try caching the dataset instead. I have seen some good tips on that around the web. And it looks like it would be ideal since your data doesn't change very often.

I realize it probably wasn't the answer you were looking for but session variables are not a very reliable way to pass data around. At least not in my experience with anything beyond classic asp. YMMV of course.
 
Back
Top