A
Aaron
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("ApplicantID") in the
page_load sub is persistant and that session variable is set from another
page, entirely!!!!
Public Class applicantactivity
Inherits System.Web.UI.Page
Protected WithEvents btnSaveFile As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnEditPersonRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNewPersonRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNewCompanyRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnClientActivity As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnApplicantActivity As
System.Web.UI.WebControls.ImageButton
Protected WithEvents txtAppInfoURL As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoEmail As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label12 As System.Web.UI.WebControls.Label
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoFax As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoPhone As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label10 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoSigOther As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoRegionLong As
System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoRegionCode As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoCountry As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoCity As System.Web.UI.WebControls.TextBox
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoAddress2 As
System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoAddress1 As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoMI As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoFirstName As
System.Web.UI.WebControls.TextBox
Protected WithEvents pnlAppInfo As System.Web.UI.WebControls.Panel
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label13 As System.Web.UI.WebControls.Label
Protected WithEvents Label14 As System.Web.UI.WebControls.Label
Protected WithEvents Label15 As System.Web.UI.WebControls.Label
Protected WithEvents txtActivityDate As
System.Web.UI.WebControls.TextBox
Protected WithEvents btnBOF As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnPrev As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNext As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnEOF As System.Web.UI.WebControls.ImageButton
Protected WithEvents pnlDashBoard As System.Web.UI.WebControls.Panel
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected AppActivityPageTitle As
System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AppActivityPageTitle.InnerText = "AppActivity - " &
Session("ApplicantFullName")
If Not Page.IsPostBack Then
Dim ApplicantActivityDS As DataSet
ApplicantActivityDS =
GetApplicantActivity(Session("ApplicantID"))
Session("CurrentRow") = 0
FillApplicantScreen(ApplicantActivityDS, Session("CurrentRow"))
End If
End Sub
Function GetApplicantActivity(ByVal ApplicantID As String)
Dim SqlCon As New SqlClient.SqlConnection()
Dim DA As New SqlClient.SqlDataAdapter()
Dim SqlCmd As New SqlClient.SqlCommand()
Dim ApplicantActivityDS As New DataSet()
Dim SQLSelectStatement As String
Dim ColumnNames As String
Dim FromClause As String
Dim WhereClause As String
Dim OrderClause As String
SqlCon = SqlQueryLibrary.BuildQuery.SQLConnect("server", "user",
"pass", "database")
SqlCmd.CommandTimeout = 60
ColumnNames = "*"
FromClause = "ApplicantActivity"
WhereClause = "Applicant_ID= " & ApplicantID
OrderClause = "date desc"
ApplicantActivityDS = SqlQueryLibrary.SQlSelect.SelectThis("server",
"user", "pass", "database", ColumnNames, FromClause, WhereClause,
OrderClause, ApplicantActivityDS)
Return ApplicantActivityDS
End Function
Sub FillApplicantScreen(ByVal ApplicantActivityDataset As DataSet, ByVal
RowNumber As Integer)
txtActivityDate.Text =
ApplicantActivityDataset.Tables(0).Rows(RowNumber).Item(16).ToString
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnNext.Click
Dim rownumber As Integer = IncrementRow()
Dim ApplicantActivityDS As DataSet
ApplicantActivityDS = GetApplicantActivity(Session("ApplicantID"))
FillApplicantScreen(ApplicantActivityDS, rownumber)
End Sub
Function IncrementRow()
Dim rownumber As Integer = Session("CurrentRow") + 1
Session("CurrentRow") = rownumber
Return rownumber
End Function
Function DecrementRow()
Dim rownumber As Integer = Session("CurrentRow") - 1
Session("CurrentRow") = rownumber
Return rownumber
End Function
End Class
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("ApplicantID") in the
page_load sub is persistant and that session variable is set from another
page, entirely!!!!
Public Class applicantactivity
Inherits System.Web.UI.Page
Protected WithEvents btnSaveFile As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnEditPersonRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNewPersonRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNewCompanyRecord As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnClientActivity As
System.Web.UI.WebControls.ImageButton
Protected WithEvents btnApplicantActivity As
System.Web.UI.WebControls.ImageButton
Protected WithEvents txtAppInfoURL As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoEmail As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label12 As System.Web.UI.WebControls.Label
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoFax As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoPhone As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label10 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoSigOther As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoRegionLong As
System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoRegionCode As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoCountry As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoCity As System.Web.UI.WebControls.TextBox
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoAddress2 As
System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoAddress1 As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents txtAppInfoMI As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAppInfoFirstName As
System.Web.UI.WebControls.TextBox
Protected WithEvents pnlAppInfo As System.Web.UI.WebControls.Panel
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label13 As System.Web.UI.WebControls.Label
Protected WithEvents Label14 As System.Web.UI.WebControls.Label
Protected WithEvents Label15 As System.Web.UI.WebControls.Label
Protected WithEvents txtActivityDate As
System.Web.UI.WebControls.TextBox
Protected WithEvents btnBOF As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnPrev As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnNext As System.Web.UI.WebControls.ImageButton
Protected WithEvents btnEOF As System.Web.UI.WebControls.ImageButton
Protected WithEvents pnlDashBoard As System.Web.UI.WebControls.Panel
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected AppActivityPageTitle As
System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AppActivityPageTitle.InnerText = "AppActivity - " &
Session("ApplicantFullName")
If Not Page.IsPostBack Then
Dim ApplicantActivityDS As DataSet
ApplicantActivityDS =
GetApplicantActivity(Session("ApplicantID"))
Session("CurrentRow") = 0
FillApplicantScreen(ApplicantActivityDS, Session("CurrentRow"))
End If
End Sub
Function GetApplicantActivity(ByVal ApplicantID As String)
Dim SqlCon As New SqlClient.SqlConnection()
Dim DA As New SqlClient.SqlDataAdapter()
Dim SqlCmd As New SqlClient.SqlCommand()
Dim ApplicantActivityDS As New DataSet()
Dim SQLSelectStatement As String
Dim ColumnNames As String
Dim FromClause As String
Dim WhereClause As String
Dim OrderClause As String
SqlCon = SqlQueryLibrary.BuildQuery.SQLConnect("server", "user",
"pass", "database")
SqlCmd.CommandTimeout = 60
ColumnNames = "*"
FromClause = "ApplicantActivity"
WhereClause = "Applicant_ID= " & ApplicantID
OrderClause = "date desc"
ApplicantActivityDS = SqlQueryLibrary.SQlSelect.SelectThis("server",
"user", "pass", "database", ColumnNames, FromClause, WhereClause,
OrderClause, ApplicantActivityDS)
Return ApplicantActivityDS
End Function
Sub FillApplicantScreen(ByVal ApplicantActivityDataset As DataSet, ByVal
RowNumber As Integer)
txtActivityDate.Text =
ApplicantActivityDataset.Tables(0).Rows(RowNumber).Item(16).ToString
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnNext.Click
Dim rownumber As Integer = IncrementRow()
Dim ApplicantActivityDS As DataSet
ApplicantActivityDS = GetApplicantActivity(Session("ApplicantID"))
FillApplicantScreen(ApplicantActivityDS, rownumber)
End Sub
Function IncrementRow()
Dim rownumber As Integer = Session("CurrentRow") + 1
Session("CurrentRow") = rownumber
Return rownumber
End Function
Function DecrementRow()
Dim rownumber As Integer = Session("CurrentRow") - 1
Session("CurrentRow") = rownumber
Return rownumber
End Function
End Class