473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cannot store arraylist in session

Hi there,

I cannot store an arraylist in a session. I have read some posts and
still found no solution. I am sure it might be something simple, but
since I have been around it for quite sometime I ask for your advice.

Here is my page load.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
Dim users As New ArrayList
users = User_.ArrayOfUsers ' This gets an array of
users. (User_ is just an object)
Session.Add("users", users)
Session.Add("i", 0)

i = 0
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users.Item(i))
Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(3).ToString
details.Clear()
users.Clear()
Else
i = CType(Session("i"), Integer)
Dim users_tmp As New ArrayList
users_tmp = CType(Session("users"), ArrayList) ' Why is
this empty?!?! I cannot understand...

detailsAfterRating =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.Item(i))
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.Item((i
+ 1)))

Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(2).ToString

RatedImage.ImageUrl = detailsAfterRating(2).ToString
lblRating.Text = detailsAfterRating(5).ToString
lblPastRate.Text = yourRating.ToString
i = (i + 1)
Session.Add("i", i)
details.Clear()
detailsAfterRating.Clear()
End If
End Sub

Mar 29 '07 #1
3 4070
See inline
Hi there,

I cannot store an arraylist in a session. I have read some posts and
still found no solution. I am sure it might be something simple, but
since I have been around it for quite sometime I ask for your advice.

Here is my page load.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
Dim users As New ArrayList
users = User_.ArrayOfUsers ' This gets an array of
users. (User_ is just an object)
Session.Add("users", users)
Here you store a *reference* to the arraylist, not the arraylist itself
Session.Add("i", 0)
i = 0
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users.Item
(i))
Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(3).ToString
details.Clear()
users.Clear()
And here you erase the 'users' list, which also erases that list in session,
as that is exactly the same list!
Else
i = CType(Session("i"), Integer)
Dim users_tmp As New ArrayList
Minor note: you don't need "new" here: you don't want to create a new instance
here as that will be overwritten in the next line
users_tmp = CType(Session("users"), ArrayList) ' Why is
this empty?!?! I cannot understand...
detailsAfterRating =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.
Item(i))
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.
Item((i
+ 1)))

Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(2).ToString
RatedImage.ImageUrl = detailsAfterRating(2).ToString
lblRating.Text = detailsAfterRating(5).ToString
lblPastRate.Text = yourRating.ToString
i = (i + 1)
Session.Add("i", i)
details.Clear()
detailsAfterRating.Clear()
End If
End Sub

Mar 29 '07 #2
On 29 Mar, 08:46, Hans Kesting <news.2.han...@spamgourmet.comwrote:
See inline


Hi there,
Icannotstoreanarraylistin asession. I have read some posts and
still found no solution. I am sure it might be something simple, but
since I have been around it for quite sometime I ask for your advice.
Here is my page load.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim users As NewArrayList
users = User_.ArrayOfUsers ' This gets an array of
users. (User_ is just an object)
Session.Add("users", users)

Here youstorea *reference* to thearraylist, not thearraylistitself
Session.Add("i", 0)
i = 0
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users.Item
(i))
Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(3).ToString
details.Clear()
users.Clear()

And here you erase the 'users' list, which also erases that list insession,
as that is exactly the same list!
Else
i = CType(Session("i"), Integer)
Dim users_tmp As NewArrayList

Minor note: you don't need "new" here: you don't want to create a new instance
here as that will be overwritten in the next line
users_tmp = CType(Session("users"),ArrayList) ' Why is
this empty?!?! Icannotunderstand...
detailsAfterRating =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.
Item(i))
details =
User_.UserID_Image_Thumbnail_LastCheck_Rating_Numb erOfVotes(users_tmp.
Item((i
+ 1)))
Image.ImageUrl = details(1).ToString
lblLastChecked.Text = details(2).ToString
RatedImage.ImageUrl = detailsAfterRating(2).ToString
lblRating.Text = detailsAfterRating(5).ToString
lblPastRate.Text = yourRating.ToString
i = (i + 1)
Session.Add("i", i)
details.Clear()
detailsAfterRating.Clear()
End If
End Sub- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Tks! That solved some issues. Still how can I then store the values
itself and not the reference?
Sorry for this, but I am quite newbie at asp.net.

Thanks.

Mar 29 '07 #3
Tks! That solved some issues. Still how can I then store the values
itself and not the reference?
You can't. Just delete the users.Clear line from your code.
Mar 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
7
by: simon | last post by:
First, I create arrayList and put it into a session. (should I use arrayList to store different types of data into collection or should I use something else?) ArrayList arrayValues = new...
1
by: Marc Bishop | last post by:
can anyone help me with this? Code Snippet: Dim ArrCart As New ArrayList() if NOT Session("sesCart") = "" then ArrCart = Session("sesCart") Error: System.InvalidCastException: Operator is...
3
by: Sukh | last post by:
I have to design a "Online Test Application" and application is going to display question and answers.All the questons are objective type so there is four answer for each question. My Question is...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
11
by: john_c | last post by:
I'd like to store information for roles in Session variables. RoleA has a specific set of values, RoleB has a specific set and so one. When I access values for RoleA, it looks like this: ...
1
by: ricardo.sobral.santos | last post by:
Hi there, I cannot store an arraylist in a session. I have read some posts and still found no solution. I am sure it might be something simple, but since I have been around it for quite sometime...
0
by: Laila2008 | last post by:
Hi, I need to add a 'WebDialog' component on to a webpage everytime a user clicks on a button. This is the error I'm getting: Cannot unregister UpdatePanel with ID 'dialog0_UpdateContainer'...
3
by: tedpottel | last post by:
Hi I cannot get sessions to work. I have the following code </body> <? session_start(); $counter++; print "You have visited this page $counter times during this session";...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.