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

Session variable value resets

Hi, I need to know if anyone else came across this. The Session
variable value I set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to its original value, the one I had set it before in the previous
trip sortcommand event handler.

I am trying to implement bidirectional sorting on a datagrid by making
use of session variable Session("SDirection"). In the sortcommand
event handler I check for its value and change it to DESC if its ASC
and vice-versa as follows:
Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
value to be the same that it was before I had made the change.

In the web.config the session configuration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>

This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.

If any one has had the same issue then please share.

thanks.

Apr 3 '07 #1
5 2843
On Apr 3, 12:03 pm, aamirghan...@gmail.com wrote:
Hi, I need to know if anyone else came across this. The Session
variable value I set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to its original value, the one I had set it before in the previous
trip sortcommand event handler.

I am trying to implement bidirectional sorting on a datagrid by making
use of session variable Session("SDirection"). In the sortcommand
event handler I check for its value and change it to DESC if its ASC
and vice-versa as follows:
Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
value to be the same that it was before I had made the change.

In the web.config the session configuration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>

This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.

If any one has had the same issue then please share.

thanks.
A couple of things I would look at right off the bat:

1. Double-check the *case* of the characters in the keys you're using
to reference the items in the session. I'm not sure if the code sample
above was pasted in, or typed from memory; I know I've run into issues
due to case-sensitivity with session keys. That is, Session("a") !=
Session("A").

2. Are you checking for the key's existence prior to retrieval? Try
setting a breakpoint, drop out to the command window in Visual Studio
and iterate over the Session.KeyNames collection and see if it's
there. It would be interesting to see if the key got dropped or
possibly overwritten.

Just a few things I can think of right off the top of my head.

Mike

Apr 3 '07 #2
It would seem to me that the easiest way to figure out what's happening is to
run this in debug mode with a breakpoint on your line of code that does the
check and makes the change to the Session variable's value.

You can examine the values and the logic each time your breakpoint is hit.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"aa**********@gmail.com" wrote:
Hi, I need to know if anyone else came across this. The Session
variable value I set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to its original value, the one I had set it before in the previous
trip sortcommand event handler.

I am trying to implement bidirectional sorting on a datagrid by making
use of session variable Session("SDirection"). In the sortcommand
event handler I check for its value and change it to DESC if its ASC
and vice-versa as follows:
Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
value to be the same that it was before I had made the change.

In the web.config the session configuration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>

This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.

If any one has had the same issue then please share.

thanks.

Apr 3 '07 #3
On Apr 3, 1:08 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Apr 3, 12:03 pm, aamirghan...@gmail.com wrote:


Hi, I need to know if anyone else came across this. TheSession
variablevalueI set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to itsoriginalvalue, the one I had set it before in the previous
trip sortcommand event handler.
I am trying to implement bidirectional sorting on a datagrid by making
use ofsessionvariableSession("SDirection"). In the sortcommand
event handler I check for itsvalueand change it to DESC if its ASC
and vice-versa as follows:
Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
valueto be the same that it was before I had made the change.
In the web.config thesessionconfiguration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>
This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.
If any one has had the same issue then please share.
thanks.

A couple of things I would look at right off the bat:

1. Double-check the *case* of the characters in the keys you're using
to reference the items in thesession. I'm not sure if the code sample
above was pasted in, or typed from memory; I know I've run into issues
due to case-sensitivity withsessionkeys. That is,Session("a") !=Session("A").

2. Are you checking for the key's existence prior to retrieval? Try
setting a breakpoint, drop out to the command window in Visual Studio
and iterate over theSession.KeyNames collection and see if it's
there. It would be interesting to see if the key got dropped or
possibly overwritten.

Just a few things I can think of right off the top of my head.

Mike- Hide quoted text -

- Show quoted text -
Thanks Mike,

I have replaced all occurrences of Session("SDirection") with
Session("SDirection") throughout the project through IDE so I can be
sure they all are of the same case.

Any way it is the same event handler that sets and then retrieves the
value in the next trip. therefore case sensitivity should not be an
issue.

Also I have looked for the clause "Session("SDirection") =" so that I
can be sure there is no other part of the code in between thats
changing the session value.

I am pretty sure that the key does not get dropped, as it is still
bringing up the old value and not totally nulling it (at least I am
not getting "object reference not set error")

thanks for the feedback again.

Apr 3 '07 #4
On Apr 3, 3:25 pm, aamirghan...@gmail.com wrote:
On Apr 3, 1:08 pm, "Mike Hofer" <kchighl...@gmail.comwrote:


On Apr 3, 12:03 pm, aamirghan...@gmail.com wrote:
Hi, I need to know if anyone else came across this. TheSession
variablevalueI set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to itsoriginalvalue, the one I had set it before in the previous
trip sortcommand event handler.
I am trying to implement bidirectional sorting on a datagrid by making
use ofsessionvariableSession("SDirection"). In the sortcommand
event handler I check for itsvalueand change it to DESC if its ASC
and vice-versa as follows:
>Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
>valueto be the same that it was before I had made the change.
In the web.config thesessionconfiguration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>
This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.
If any one has had the same issue then please share.
thanks.
A couple of things I would look at right off the bat:
1. Double-check the *case* of the characters in the keys you're using
to reference the items in thesession. I'm not sure if the code sample
above was pasted in, or typed from memory; I know I've run into issues
due to case-sensitivity withsessionkeys. That is,Session("a") !=Session("A").
2. Are you checking for the key's existence prior to retrieval? Try
setting a breakpoint, drop out to the command window in Visual Studio
and iterate over theSession.KeyNames collection and see if it's
there. It would be interesting to see if the key got dropped or
possibly overwritten.
Just a few things I can think of right off the top of my head.
Mike- Hide quoted text -
- Show quoted text -

Thanks Mike,

I have replaced all occurrences of Session("SDirection") with
Session("SDirection") throughout the project through IDE so I can be
sure they all are of the same case.

Any way it is the same event handler that sets and then retrieves the
value in the next trip. therefore case sensitivity should not be an
issue.

Also I have looked for the clause "Session("SDirection") =" so that I
can be sure there is no other part of the code in between thats
changing the session value.

I am pretty sure that the key does not get dropped, as it is still
bringing up the old value and not totally nulling it (at least I am
not getting "object reference not set error")

thanks for the feedback again.- Hide quoted text -

- Show quoted text -
Found the solution:
The dgrid was being sorted twice hence the Sortcommand was being
called twice and I would see the final sorted result. Session variable
SDirection was being set twice first from ASC to DESC and then back
again to ASC. therefore I would not see any change in the sort order.
All this was happening because the sortcommand event handler was
mentioned twice. Once declared in the onSortCommand attribute of the
datagrid in te aspx page and then again by adding "Handles
dgrid.SortCommand" in the definition of the actual event handler in
codefile.

Thanks.

Apr 4 '07 #5
On Apr 3, 3:25 pm, aamirghan...@gmail.com wrote:
On Apr 3, 1:08 pm, "Mike Hofer" <kchighl...@gmail.comwrote:


On Apr 3, 12:03 pm, aamirghan...@gmail.com wrote:
Hi, I need to know if anyone else came across this. TheSession
variablevalueI set in a sortCommand event handler of a datagrid does
not hold on till the next sortcommand event handler and reverts back
to itsoriginalvalue, the one I had set it before in the previous
trip sortcommand event handler.
I am trying to implement bidirectional sorting on a datagrid by making
use ofsessionvariableSession("SDirection"). In the sortcommand
event handler I check for itsvalueand change it to DESC if its ASC
and vice-versa as follows:
>Session("SDirection") = IIf(Session("SDirection") = "ASC", "DESC",
"ASC")
For the sake of simplicity I am not checking for the column in the
above code ... just the direction.
It sorts the dgrid fine for that pass, but next time a column (or same
column) header is clicked then in the sortcommand handler I find the
>valueto be the same that it was before I had made the change.
In the web.config thesessionconfiguration looks like this:
<sessionState mode="InProc" cookieless="AutoDetect" timeout="20"/>
This app was originally in .Net 1.1 and was working perfectly fine
(and is on the 1.1 framework), but after converting it to 2.0 it has
lost this functionality.
If any one has had the same issue then please share.
thanks.
A couple of things I would look at right off the bat:
1. Double-check the *case* of the characters in the keys you're using
to reference the items in thesession. I'm not sure if the code sample
above was pasted in, or typed from memory; I know I've run into issues
due to case-sensitivity withsessionkeys. That is,Session("a") !=Session("A").
2. Are you checking for the key's existence prior to retrieval? Try
setting a breakpoint, drop out to the command window in Visual Studio
and iterate over theSession.KeyNames collection and see if it's
there. It would be interesting to see if the key got dropped or
possibly overwritten.
Just a few things I can think of right off the top of my head.
Mike- Hide quoted text -
- Show quoted text -

Thanks Mike,

I have replaced all occurrences of Session("SDirection") with
Session("SDirection") throughout the project through IDE so I can be
sure they all are of the same case.

Any way it is the same event handler that sets and then retrieves the
value in the next trip. therefore case sensitivity should not be an
issue.

Also I have looked for the clause "Session("SDirection") =" so that I
can be sure there is no other part of the code in between thats
changing the session value.

I am pretty sure that the key does not get dropped, as it is still
bringing up the old value and not totally nulling it (at least I am
not getting "object reference not set error")

thanks for the feedback again.- Hide quoted text -

- Show quoted text -
Found the solution:
The dgrid was being sorted twice hence the Sortcommand was being
called twice and I would see the final sorted result. Session
variable
SDirection was being set twice first from ASC to DESC and then back
again to ASC. therefore I would not see any change in the sort order.
All this was happening because the sortcommand event handler was
mentioned twice. Once declared in the onSortCommand attribute of the
datagrid in te aspx page and then again by adding "Handles
dgrid.SortCommand" in the definition of the actual event handler in
codefile.

I checked the 1.1 code which still sorts fine even it had the event
handler mentoned twice. Is this new behavior in 2.0 a bug or by
design?

Thanks.


Apr 4 '07 #6

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

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
3
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working...
1
by: farooqazeem | last post by:
Hi guys, I’m facing some problem can u solve it. Problem is: I’m giving user Id and password in (Login_sess.asp) and submit it to page (sess_test.asp). I am setting session variable...
6
by: -D- | last post by:
I'm trying to accomplish the following. I'm trying to get the values for the table rows that are dynamically created to persist through a redirect. Referring URL:...
2
by: kai | last post by:
Hi, All I put Drop Down List on a ASP.NET form, it contains "CustomerID" from Northwind Database from SQL Server 2000 "Customers" table. I use SqlDataAdapter, SqlConnection and DataSet control to...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
2
by: Tomas Martinez | last post by:
Hi, Well, my problem is so simple as it says in the subjet but very frustrating also. I have a project and it is losing the session variables with each postback, so I downloaded from the web a...
5
by: TRB_NV | last post by:
I'm losing information from my Session when I change pages or start the same page over again. I simplified the code so the example is really clear. The sample code that follows is supposed to...
4
by: Sarah Marriott | last post by:
Our website contains session variables that are used to validate if a user is logged in etc. We have found that these variables are randomly lost while navigating the website. We set up some...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.