473,569 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help with this problem. I am stoopid. (regarding session vars)

Why do my session values return to nothing on post back?

I want to click a button and have the row, as in: dataset.table(0 ).rows(THIS
ROW NUMBER IS WHAT I AM TALKING ABOUT), either increment or decrement to
facilitate a movenext and movelast. I have been pulling my hair out and am
at the end of my rope.

PLEASE, how should I implement this? I have tried everything I can think
of, which really isn't much considering I am just beginning my forray into
vb.net programming. I have included all of my code.

I think that I am almost there, (I think) I just need to understand why my
session variables (in the IncrementRow and DecrementRow functions) keep
getting set to zero on post back. The Session("Applic antID") in the
page_load sub is persistant and that session variable is set from another
page, entirely!!!!

Public Class applicantactivi ty
Inherits System.Web.UI.P age
Protected WithEvents btnSaveFile As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnEditPersonRe cord As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnNewPersonRec ord As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnNewCompanyRe cord As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnClientActivi ty As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnApplicantAct ivity As
System.Web.UI.W ebControls.Imag eButton
Protected WithEvents txtAppInfoURL As System.Web.UI.W ebControls.Text Box
Protected WithEvents txtAppInfoEmail As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label12 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label11 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoFax As System.Web.UI.W ebControls.Text Box
Protected WithEvents txtAppInfoPhone As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label10 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label9 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label8 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label7 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoSigOt her As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label6 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoRegio nLong As
System.Web.UI.W ebControls.Text Box
Protected WithEvents txtAppInfoRegio nCode As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label5 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoCount ry As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label4 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoCity As System.Web.UI.W ebControls.Text Box
Protected WithEvents Label3 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoAddre ss2 As
System.Web.UI.W ebControls.Text Box
Protected WithEvents txtAppInfoAddre ss1 As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label2 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtAppInfoMI As System.Web.UI.W ebControls.Text Box
Protected WithEvents txtAppInfoFirst Name As
System.Web.UI.W ebControls.Text Box
Protected WithEvents pnlAppInfo As System.Web.UI.W ebControls.Pane l
Protected WithEvents TextBox2 As System.Web.UI.W ebControls.Text Box
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label13 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label14 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label15 As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtActivityDate As
System.Web.UI.W ebControls.Text Box
Protected WithEvents btnBOF As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnPrev As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnNext As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents btnEOF As System.Web.UI.W ebControls.Imag eButton
Protected WithEvents pnlDashBoard As System.Web.UI.W ebControls.Pane l

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region
Protected AppActivityPage Title As
System.Web.UI.H tmlControls.Htm lGenericControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
AppActivityPage Title.InnerText = "AppActivit y - " &
Session("Applic antFullName")
If Not Page.IsPostBack Then
Dim ApplicantActivi tyDS As DataSet
ApplicantActivi tyDS =
GetApplicantAct ivity(Session(" ApplicantID"))
Session("Curren tRow") = 0
FillApplicantSc reen(ApplicantA ctivityDS, Session("Curren tRow"))
End If
End Sub

Function GetApplicantAct ivity(ByVal ApplicantID As String)
Dim SqlCon As New SqlClient.SqlCo nnection()
Dim DA As New SqlClient.SqlDa taAdapter()
Dim SqlCmd As New SqlClient.SqlCo mmand()
Dim ApplicantActivi tyDS As New DataSet()
Dim SQLSelectStatem ent As String
Dim ColumnNames As String
Dim FromClause As String
Dim WhereClause As String
Dim OrderClause As String
SqlCon = SqlQueryLibrary .BuildQuery.SQL Connect("server ", "user",
"pass", "database")
SqlCmd.CommandT imeout = 60
ColumnNames = "*"
FromClause = "ApplicantActiv ity"
WhereClause = "Applicant_ ID= " & ApplicantID
OrderClause = "date desc"
ApplicantActivi tyDS = SqlQueryLibrary .SQlSelect.Sele ctThis("server" ,
"user", "pass", "database", ColumnNames, FromClause, WhereClause,
OrderClause, ApplicantActivi tyDS)
Return ApplicantActivi tyDS
End Function

Sub FillApplicantSc reen(ByVal ApplicantActivi tyDataset As DataSet, ByVal
RowNumber As Integer)
txtActivityDate .Text =
ApplicantActivi tyDataset.Table s(0).Rows(RowNu mber).Item(16). ToString
End Sub

Private Sub btnNext_Click(B yVal sender As System.Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnNext.Click
Dim rownumber As Integer = IncrementRow()
Dim ApplicantActivi tyDS As DataSet
ApplicantActivi tyDS = GetApplicantAct ivity(Session(" ApplicantID"))
FillApplicantSc reen(ApplicantA ctivityDS, rownumber)
End Sub
Function IncrementRow()
Dim rownumber As Integer = Session("Curren tRow") + 1
Session("Curren tRow") = rownumber
Return rownumber
End Function
Function DecrementRow()
Dim rownumber As Integer = Session("Curren tRow") - 1
Session("Curren tRow") = rownumber
Return rownumber
End Function
End Class
Nov 21 '05 #1
3 1558
Aaron,

I thought that you did not store the datasets between the post. The easiest
is to save it just in a session and when the page isposted back (in the else
root of that in your load event) to restore it again to the dataset

In a webpage is all really stateless, so that means that when you do not
reload it after a postback it will not be there.

I do not know if that is the only thing.

I hope this helps?

Cor
Nov 21 '05 #2
I think I am on the right track if I can figure out how to get my
Session("Curren tRow") to persist. Can you see why it gets set back to 0?
I do not have any problems accessing the dataset, my problem is when I
debug, the first time the page loads, Session("Curren tRow") is set to 0.
When I hit the movenext button, the session is incremented by one to "1".
When I hit the button again, I see that the value if Session("Curren tRow") =
0 again, and then it gets incremented to "1" with the IncrementRow
function. I can not get past 1.

If your point is that I am re-retrieving the data, that is another issue
that I can work on. Right now I am concentrating on moving on to the next
row and beyond. Then I have to be able to move backward, to BOF and EOF, as
well. I guess I will try to keep that dataset in a session variable, but
right now I can't even get a basic integer to stick around long enough...

Perhaps some code examples of how you might navigate dataset rows in an
ASP.NET environment would be helpful.

Protected AppActivityPage Title As
System.Web.UI.H tmlControls.Htm lGenericControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
AppActivityPage Title.InnerText = "AppActivit y - " &
Session("Applic antFullName")
If Not Page.IsPostBack Then
Dim ApplicantActivi tyDS As DataSet
ApplicantActivi tyDS =
GetApplicantAct ivity(Session(" ApplicantID"))
Session("Curren tRow") = 0
FillApplicantSc reen(ApplicantA ctivityDS, Session("Curren tRow"))
End If
End Sub

Function GetApplicantAct ivity(ByVal ApplicantID As String)
Dim SqlCon As New SqlClient.SqlCo nnection()
Dim DA As New SqlClient.SqlDa taAdapter()
Dim SqlCmd As New SqlClient.SqlCo mmand()
Dim ApplicantActivi tyDS As New DataSet()
Dim SQLSelectStatem ent As String
Dim ColumnNames As String
Dim FromClause As String
Dim WhereClause As String
Dim OrderClause As String
SqlCon = SqlQueryLibrary .BuildQuery.SQL Connect("server ", "user",
"pass", "database")
SqlCmd.CommandT imeout = 60
ColumnNames = "*"
FromClause = "ApplicantActiv ity"
WhereClause = "Applicant_ ID= " & ApplicantID
OrderClause = "date desc"
ApplicantActivi tyDS = SqlQueryLibrary .SQlSelect.Sele ctThis("server" ,
"user", "pass", "database", ColumnNames, FromClause, WhereClause,
OrderClause, ApplicantActivi tyDS)
Return ApplicantActivi tyDS
End Function

Sub FillApplicantSc reen(ByVal ApplicantActivi tyDataset As DataSet, ByVal
RowNumber As Integer)
txtActivityDate .Text =
ApplicantActivi tyDataset.Table s(0).Rows(RowNu mber).Item(16). ToString
End Sub

Private Sub btnNext_Click(B yVal sender As System.Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles btnNext.Click
Dim rownumber As Integer = IncrementRow()
Dim ApplicantActivi tyDS As DataSet
ApplicantActivi tyDS = GetApplicantAct ivity(Session(" ApplicantID"))
FillApplicantSc reen(ApplicantA ctivityDS, rownumber)
End Sub
Function IncrementRow()
Dim rownumber As Integer = Session("Curren tRow") + 1
Session("Curren tRow") = rownumber
Return rownumber
End Function
Function DecrementRow()
Dim rownumber As Integer = Session("Curren tRow") - 1
Session("Curren tRow") = rownumber
Return rownumber
End Function
Nov 21 '05 #3

"Aaron" <aa***@jonharve y.com> wrote in message
news:O3******** *****@TK2MSFTNG P11.phx.gbl...
I think I am on the right track if I can figure out how to get my
Session("Curren tRow") to persist. Can you see why it gets set back to 0?


Not from the code you posted. Do a search for >>> Session("Curren tRow") = 0
<<< and make sure the Page_Load is the ONLY place you're setting this to 0.
Nov 21 '05 #4

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

Similar topics

13
23288
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 The problem I am having is that each time I reload the same PHP page, I get
0
1285
by: Michael J. Wendell | last post by:
Hello, I am trying to debug an issue with sessions in my ASP 3.0 web application, which runs fine on WIN2K Pro and WINXP Pro, yet fails to function correctly on WIN2K Advanced Server. My actual application is using sessions to store username, and security level (permissions) for my application. The default.asp page is the login, where...
4
1915
by: Kenny Ashton | last post by:
Hello gurus Can I ask you opions on the best compromise for storing Access Ado connection strings in a IIS4 standard ASP environment. For any method I use, there seems to be an article somewhere that says 'never' do this, or that. 1. I have 3 site folders s1, s2, s2 and a common DB folder outside the site roots. /sites/s1 /sites/s2
7
2300
by: Adam Short | last post by:
I'm having all sorts of problems with Sessions, I've been using them for years with out a hitch, all of a sudden the last 6 - 12 months since getting our new Win2003 server it's all gone shakey!!! Our development server started life as an NT4 machine and has been simply upgraded from one operating system to the next, it is now a cross, NT4...
7
2024
by: Nicole | last post by:
Hi I'm trying to use a function to set a session variable. I have three files: The first file has: <?php session_start(); // This connects to the existing session ?> <html> <head>
6
1614
by: JDP | last post by:
First off let me say that http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp would not work as I see it. Right off, I can't have a cookie. Anyway, another solution suggests using hidden form fields only helps me to know that there is a way, I don't know how to pass a hidden form field from...
5
8890
by: VB Programmer | last post by:
I often use session variables to store the user's security level, and other important info. How secure are session variables? Can someone decrypt it and get the information? (This would be especially important to know if the session vars contain things like credit card numbers.) Any better, more secure alternatives? How would you store...
5
6121
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request scope. Application variables are then accessed in this manner Request.App.<Var>. To begin with I had a simple functioning login system inside a...
4
6287
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59 Notice: Undefined index: args in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92 Warning: Invalid argument supplied for...
0
7695
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...
0
7612
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...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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...
0
6281
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.