What would be the best way to create a dynamic array for a user to add products to a basket then store them in a session variable, I have been told serilizable arrays would work however when looking online for a solution I came accross an ArrayList which seemed perfect but I can’t seem to implement it.
I have a separate class called Basket with:
ArrayList basketItems = new ArrayList();
I need to be able to select a product from a gridview using the select link or alternatively using a listview and using my own button to then add the bookID to the array, which will then be stored in a session variable and sent to a basket page where the bookID will be used again against a SQL table to output the details of the book etc.
If we were in 2003 then yes,
ArrayListcould have worked fine but now I would recommend you using a genericList<T>which will be type safe and you don’t need casting.So you could have the following collection: