473,748 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles Me.Load

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

i = 0
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users.Item(i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
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...

detailsAfterRat ing =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.Item( i))
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.Item( (i
+ 1)))

Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(2).ToSt ring

RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = yourRating.ToSt ring
i = (i + 1)
Session.Add("i" , i)
details.Clear()
detailsAfterRat ing.Clear()
End If
End Sub

Mar 29 '07 #1
3 4105
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.EventArg s) Handles Me.Load

If Not Page.IsPostBack Then
Dim users As New ArrayList
users = User_.ArrayOfUs ers ' This gets an array of
users. (User_ is just an object)
Session.Add("us ers", users)
Here you store a *reference* to the arraylist, not the arraylist itself
Session.Add("i" , 0)
i = 0
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users.Item
(i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
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...
detailsAfterRat ing =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.
Item(i))
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.
Item((i
+ 1)))

Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(2).ToSt ring
RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = yourRating.ToSt ring
i = (i + 1)
Session.Add("i" , i)
details.Clear()
detailsAfterRat ing.Clear()
End If
End Sub

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


Hi there,
Icannotstoreana rraylistin 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.EventArg s) Handles Me.Load
If Not Page.IsPostBack Then
Dim users As NewArrayList
users = User_.ArrayOfUs ers ' This gets an array of
users. (User_ is just an object)
Session.Add("us ers", users)

Here youstorea *reference* to thearraylist, not thearraylistits elf
Session.Add("i" , 0)
i = 0
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users.Item
(i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
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"),ArrayLi st) ' Why is
this empty?!?! Icannotundersta nd...
detailsAfterRat ing =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.
Item(i))
details =
User_.UserID_Im age_Thumbnail_L astCheck_Rating _NumberOfVotes( users_tmp.
Item((i
+ 1)))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(2).ToSt ring
RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = yourRating.ToSt ring
i = (i + 1)
Session.Add("i" , i)
details.Clear()
detailsAfterRat ing.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
5478
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
7
504
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 ArrayList(); arrayValues = lstMedia.SelectedValue;// this is int arrayValues = MediaCalendar.xSelectedDate.Date;//this is datetime HttpContext.Current.Session = arrayValues; Then, I want to change the value : HttpContext.Current.session = 0;
1
1331
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 not valid for type 'ArrayList' and string "".
3
1395
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 where I shuld store the questions and answers. and how application can pick randomly question. right now I have all question in a text file. Please give me suggestion. I am using C# and asp.net for this. Regards, Sukh.
6
3140
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 to the client. Before adding data to the arraylist, I check if the depth of the arraylist is longer than iMaxQueueDepth, and if it is, I clear the arraylist. Is it possible that while I am clearing the arraylist, the ThreadMain at the same time...
11
3033
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: Session = "30" Session = "1000" Session = "5" Session = "10" and similar for the other roles. Those values are initially loaded
1
1071
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 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
0
5017
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' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported. Parameter name: updatePanel I get the error here: ...
3
2318
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"; session_register("counter");
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.