Session State ArrayList in Shopping Cart ASP.NET

Posted by user330342 on Stack Overflow See other posts from Stack Overflow or by user330342
Published on 2010-05-01T12:16:22Z Indexed on 2010/05/01 12:27 UTC
Read the original article Hit count: 166

Filed under:
|

Hi guys,

I'm creating a shopping cart application and I'm having some issues with implementing a session state for my arraylist.

in my page load i declared

 if (Session["Cart"] == null)
        {
            Session["Cart"] = new ArrayList();
        }

        else
        { 
            ArrayList cart = (ArrayList)Session["Cart"];
        }

to create the session if it doesn't exist yet. then i have an event handler for a button to add items to the arraylist

protected void onClick_AddBooking(object sender, EventArgs e)
    {
        int ClassID = Convert.ToInt32(Request.QueryString.Get("Class_Id"));
        ArrayList cart1 = new ArrayList();

        cart1 = Session["Cart"];       

        cart1.Add(ClassID);

i'm guessing i just don't know how to handle session states yet, thus the confusion. I'm essentially storing the class_ID then when the student confirms i'll store that to the DB and associate that ID with the Class Details.

Thanks in advance guys!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about session-state