473,378 Members | 1,456 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,378 software developers and data experts.

Session Variables Strange Behaviour

Hi all,
I'm having a problem with session variables in vs .net 2003. I start by
doing this:
If Not IsPostBack Then
Dim dt As DataTable
Me.daAlias.Fill(Me.DsPhysicalAlias)
dt = Me.DsPhysicalAlias.Tables(0)
Session("tblAlias") = dt
Session("tblAliasOriginal") = dt
BindGrid()
End If
I want to load dt into two session variables, make whatever changes I want
to tblAlias, and then, compare it with tblAliasOriginal, to see the changes
I've made.
I have a datagrid to make changes to tblAlias and I delete a row using:

Dim dtAlias As DataTable
dtAlias = Session("tblAlias")
dtAlias.Rows(e.Item.ItemIndex).Delete()
dtAlias.AcceptChanges()

Session("tblAlias")
BindGrid()
My problem is that when I delete a row in tblAlias, that row is also deleted
from tblAliasOriginal! Why? How can I prevent this?
Mar 14 '06 #1
1 1001
Both session variables are pointing to the same object. There is only ever
1 object in memory - and both tblAlias and tblAliasOriginal are pointing to
it.

I recommend you read up on object references, and what it is to be a
reference type versus a value type.

"Nuno Carvalho" <Nuno Ca******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
Hi all,
I'm having a problem with session variables in vs .net 2003. I start by
doing this:
If Not IsPostBack Then
Dim dt As DataTable
Me.daAlias.Fill(Me.DsPhysicalAlias)
dt = Me.DsPhysicalAlias.Tables(0)
Session("tblAlias") = dt
Session("tblAliasOriginal") = dt
BindGrid()
End If
I want to load dt into two session variables, make whatever changes I want
to tblAlias, and then, compare it with tblAliasOriginal, to see the
changes
I've made.
I have a datagrid to make changes to tblAlias and I delete a row using:

Dim dtAlias As DataTable
dtAlias = Session("tblAlias")
dtAlias.Rows(e.Item.ItemIndex).Delete()
dtAlias.AcceptChanges()

Session("tblAlias")
BindGrid()
My problem is that when I delete a row in tblAlias, that row is also
deleted
from tblAliasOriginal! Why? How can I prevent this?

Mar 14 '06 #2

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

Similar topics

2
by: Newbie | last post by:
Hi All, I would really appreciate any ideas / clues on this issue which I am facing. I have a asp.net application, the problem is with maintaining session variables while using authentication for...
1
by: Wiktor Zychla | last post by:
Hello there, I've just encountered a strange problem with Session. In one particular scenario it is cleared between pages but the scenario is so specific that I am really, really startled. I've...
4
by: Aidas Pasilis | last post by:
I'm saving some values to the Session state and get some strange results. To be short I'll write example code and standart behavior: Code Example:...
9
by: Randy | last post by:
Hello, I'm having a strange problem. I've got a .NET web app which uses Session variables. Sometime, not all the time, they get cross threaded...that is...one user will have another user's Session...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
3
by: Lee Moore | last post by:
I have some user controls defined that represent a common header and footer for a particular site. the footer contains links with querystring parameters based on session variables. The problem is,...
7
by: Victor | last post by:
I've got two domain names sharing the same IP address that use ASP VBScript If I set a session variable with domain 1, it is only available for domain 1 - this is correct? If I set an...
10
by: isynclere | last post by:
Hi all, I am stuck with a very strange session prob. Developing on locahost. Have just gone back to a project I was working on to check all is ok and the login function is no longer working...
11
Dormilich
by: Dormilich | last post by:
recently I encounter a very strange behaviour of the session variable. if the cookies are disabled, the session id is totally misplaced (see code). instead being attached to the URL it is placed...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.