'click button to start
Sub btnDisplayPagingPhotos_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim varPhotosID As String = 24
session("thePageSize") = 7
Timer1.Interval = 7 'seconds
GetPhotos(varPhotosID)
End Sub
Private Sub GetPhotos(ByVal photosid As String)
Dim ssql As String
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings.Get("cnn"))
cnn.Open()
ssql = "exec procGetPhotos '" & photosid & "'"
pnlViewPhotos.visible = True
session("da") = New SqlDataAdapter(ssql, cnn)
session("ds") = New DataSet
session("da").Fill(session("ds"), "photos")
session("dtPhotosSource") = session("ds").Tables("photos")
getPhotosData()
cnn.Close()
End Sub
Private Sub goToFirstSetOfPhotos()
If session("theCurrentPage") = 1 Then
Return
End If
session("theCurrentPage") = 1
session("theRecordNumber") = 0
LoadPhotos()
End Sub
Private Sub LoadPhotos()
Timer1.Interval = ddlPagingInterval.SelectedItem.Value
session("dtTemp") = session("dtPhotosSource").Clone
If session("theCurrentPage") = session("thePageCount") Then
session("endRec") = session("theMaxRecord")
Else
session("endRec") = session("thePageSize") * session("theCurrentPage")
End If
session("startRec") = session("theRecordNumber")
'if photos actually exist
Dim intCount As Integer
intCount = session("dtPhotosSource").Rows.Count
If intCount > 0 Then
Dim i As Integer
For i = session("startRec") To session("endRec") - 1
session("dtTemp").ImportRow(session("dtPhotosSource").Rows(i))
session("theRecordNumber") = session("theRecordNumber") + 1
Next
End If
dgPhotos.DataSource = session("dtTemp")
dgPhotos.Databind()
End Sub
Private Sub getPhotosData()
session("theMaxRecord") = session("dtPhotosSource").Rows.Count
session("thePageCount") = session("theMaxRecord") \ session("thePageSize")
If (session("theMaxRecord") Mod session("thePageSize")) > 0 Then
session("thePageCount") = session("thePageCount") + 1
End If
session("theCurrentPage") = 1
session("theRecordNumber") = 0
LoadPhotos()
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Elapsed
session("theCurrentPage") = session("theCurrentPage") + 1
If session("theCurrentPage") > session("thePageCount") Then
session("theCurrentPage") = session("thePageCount")
If session("theRecordNumber") = session("theMaxRecord") Then
session("theCurrentPage") = 1
getPhotosData()
goToFirstSetOfPhotos()
Dim varPhotosID As String = 24
GetPhotos(photosid)
Return
End If
End If
LoadPhotos()
End Sub