Hi All,
This has nothing to do with llblgen, but your all are quite knowledgable and friendly that I thought I would pass this by you. I'm trying to encapsulate the session variables like so:
#Region " Imports "
Imports Microsoft.VisualBasic
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL.EntityClasses
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL.DatabaseSpecific
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL.FactoryClasses
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL.RelationClasses
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL.HelperClasses
Imports MedfordSchoolDistrict.Elementary.GradeBook.LLBL
Imports MedfordSchoolDistrict.ElementaryGradeBookBLL
Imports MedfordSchoolDistrict.ElementaryCommon
Imports MedfordSchoolDistrict
Imports Infragistics.WebUI
Imports System.Collections.Generic
Imports System.Web.SessionState.HttpSessionState
Imports System.data
Imports SD.LLBLGen.Pro.ORMSupportClasses
#End Region
Public Class UserData
Public Shared SessionName As String = "UserData"
Public UserName As String
Private _StudentAssignmentTable As DataTable
Public Property StudentAssignmentTable() As DataTable
Get
If _StudentAssignmentTable Is Nothing Then
_StudentAssignmentTable = DirectCast(HttpContext.Current.Session.Item("StudentAssignmentTable"), DataTable)
End If
Return _StudentAssignmentTable
End Get
Set(ByVal value As DataTable)
_StudentAssignmentTable = value
HttpContext.Current.Session.Add("StudentAssignmentTable", value)
End Set
End Property
Then the Page_Load is:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
_UserData = New UserData
RetrieveUserInformation()
Session(UserData.SessionName) = _UserData
drpTerm.Text = "1"
ElementaryCommon.SchoolCalendar.CurrentDate = Now
'TODO: I first need the SchoolEntity before I can calculate term. Not sure if I'm going to do this.
'drpTerm.Text = ElementaryWebGradeBookBll.SchoolCalendar.CurrentTerm
Else
If Session(UserData.SessionName) IsNot Nothing Then
_UserData = DirectCast(Session(UserData.SessionName), UserData)
Else
'TODO: Send to time out
End If
End If
End Sub
Then I'll access an item like:
Protected Sub ScoreChange(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ScoreValue As TextBox = CType(sender, TextBox)
Dim Index As Integer = CType(ScoreValue.Parent.Parent, GridViewRow).DataItemIndex
Dim dvr As DataRowView = _UserData.StudentAssignmentTable.DefaultView(Index)
End Sub
It seems to work. I just would like to know if this is a good way to do this or if a better way exists.
Thanks,
Fishy