|
-
Jan 30th, 2004, 07:44 AM
#1
Thread Starter
Frenzied Member
How to get values from session objects?
I ahve a collection object saved in the session
I have also declared a new collection object
When I do the following(written from memory )
dim newcoll as new collection
newcoll = Cast(Session("Collection"), Collection)
I get only a reference to the session collection.. so when I am editing newcoll I am manipulating the sessions collection...
How can I get the value?
kind regarrds
Henrik
-
Jan 30th, 2004, 09:26 AM
#2
Fanatic Member
isn't this ASP.NET?
when i store a dataset as a session object I don't cast it when getting the value back and it seems to work ok.
-
Jan 30th, 2004, 09:54 AM
#3
Thread Starter
Frenzied Member
yes it's asp.net...
The problem we are having is that when we perform the cast, a reference to the object in session. SO when we alter the values in the collection... the session collection is altered... not what we wanted.
I know byref is default in .net...
kinds regards
Henrik
-
Jan 30th, 2004, 11:00 AM
#4
If you don't want to alter the session collection then why are you using it? I'm confused.
VB Code:
dim newcoll as new collection
'this assigns the collection object created in the last line to
'the session collection instead of the one created
'in fact using New here does nothing since you assign it
'to another collection in the next line
newcoll = DirectCast(Session("Collection"), Collection)
Are you trying to work with a copy of the collection? If so then you'll need to write a routine that actually copies the properties of the items to new items and adds them to the new collection. This all happens because the collection object is a reference type not a value type.
Last edited by Edneeis; Feb 2nd, 2004 at 02:31 AM.
-
Feb 2nd, 2004, 01:39 AM
#5
Thread Starter
Frenzied Member
Actually Im asking for a friend.. he asked me and I didn't have a perfect answer to him, so I decided to ask the pros here... I was 99 % sure it was a reference issue but needed to be sure... thanks for the answer.. I have no clue why he want to do it like this
kind regards
Henrik
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|