John Smith wrote:
Just out of curiosity, what is your objection to the session object?
I am beginner and I have never used it before. I'll try it now.
Ah!
I typically use a pattern like this in my pages:
Private _CachedDS as dataset
Private Propery CachedDS() as dataset
Get
If _CachedDS Is Nothing Then
If Not Session("CachedDS") Is Nothing Then
_CachedDS = CType(Session("CachedDS"), dataset)
End If
End If
Return _CachedDS
End Get
Set(ByVal Value As dataset)
Session("CachedDS") = Value
_CachedDS = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
BindDataGrid()
End If
End Sub
....
Sub BindDataGrid
Dim ds as dataset
if CachedDS Is Nothing then
FillDataSet()
End If
'bind the grid
Dim ds as dataset=CachedDS
With DataGrid1
.DataSource=ds
.DataMember = ...
.DataBind
End With
End Sub
Sub FillDataSet()
Try
CachedDS = DataLayer.RetrieveData(parms)
Catch ex
'handle error
End Try
End Sub
Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex
Dim ds As DataSet
if not CachedDS is Nothing then
ds = CachedDS
Else
'throw an error? call FillDataset? up to you.
End If
Dim row As DataRow
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text +
"'")(0)
etc.
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.