Private Sub pInitializeVariables()
Dim objProd As New clsProducts()
Dim DS As dpDataSet
Dim intProductCount As Integer
Dim strCategoryId As String = G_Request("CatId")
Dim strConditionId As String = G_Request("CondId")
If strCategoryId <> "" Then
DS = objProd.GetAllByCategory(CType(Page, WF_BaseClass).objDataPass, strCategoryId)
ElseIf strConditionId <> "" Then
DS = objProd.GetAllByCondition(CType(Page, WF_BaseClass).objDataPass, strConditionId)
Else
strCategoryId = "2041"
DS = objProd.GetAllByCategory(CType(Page, WF_BaseClass).objDataPass, strCategoryId)
End If
'*******************
' get product count
'*******************
intProductCount = DS.ResultDataSet.Tables(0).Rows.Count
'*******************
' set up paging - 25 items max per page
'*******************
Dim intPageCount As Integer = Math.Ceiling(intProductCount / 25)
Dim intLastPageItemCount As Integer = (intProductCount Mod 25)
Dim intPageNumber As Integer
Dim intStartRow As Integer
Dim intMaxRecords As Integer
Dim x As Integer
Dim myDS As New DataSet("MyDataset")
Dim dTable As New DataTable("MyTable")
Dim dRow As DataRow
If G_Request("PageNumber") = "" Or G_Request("PageNumber") = "1" Then
intPageNumber = 1
intStartRow = 0
Else
intPageNumber = CType(G_Request("PageNumber"), Integer)
intStartRow = ((intPageNumber - 1) * 25)
End If
If intPageCount <> intPageNumber Then
intMaxRecords = 24
Else
intMaxRecords = intLastPageItemCount - 1
End If
'***************************
' populate a dataset with subset of data
' based on starting row and max records
'***************************
myDS.Tables.Add(dTable)
For x = 0 To DS.ResultDataSet.Tables(0).Columns.Count - 1
dTable.Columns.Add(DS.ResultDataSet.Tables(0).Columns(x).ColumnName, DS.ResultDataSet.Tables(0).Columns(x).DataType)
Next
Dim y As Integer
For x = intStartRow To (intStartRow + intMaxRecords)
dRow = dTable.NewRow
For y = 0 To dTable.Columns.Count - 1
dRow(y) = DS.ResultDataSet.Tables(0).Rows(x)(y)
Next
dTable.Rows.Add(dRow)
Next
'*********************
' set up navigation by page number
'*********************
lblPaging.Text = ""
If intPageCount <> 1 Then
For x = 1 To intPageCount
If intPageNumber <> x Then
If strCategoryId <> "" Then
lblPaging.Text += "<a href=""" & mBaseUrl & "?PageNumber=" & x.ToString & "&CatId=" & strCategoryId & """>" & x.ToString & "</a> | "
ElseIf strConditionId <> "" Then
lblPaging.Text += "<a href=""" & mBaseUrl & "?PageNumber=" & x.ToString & "&CondId=" & strConditionId & """>" & x.ToString & "</a> | "
Else
lblPaging.Text += "<a href=""" & mBaseUrl & "?PageNumber=" & x.ToString & "&CatId=" & strCategoryId & """>" & x.ToString & "</a> | "
End If
Else
lblPaging.Text += intPageNumber.ToString & " | "
End If
Next
lblPaging.Text = lblPaging.Text.Substring(0, lblPaging.Text.Length - 3)
End If
'*******************
' populate repeater based on display type
'*******************
rptList.Visible = False
rptThumblist.visible = False
rptThumbrow.visible = False
Select Case rblDisplay.SelectedItem.Value
Case "list"
With rptList
.Visible = True
.DataSource = myDS.Tables(0).DefaultView
.DataBind()
End With
Case "thumblist"
With rptThumblist
.Visible = True
.DataSource = myDS.Tables(0).DefaultView
.DataBind()
End With
Case "thumbrows"
With rptThumbrow
.Visible = True
.DataSource = myDS.Tables(0).DefaultView
.DataBind()
End With
End Select
'*******************
' display product count
'*******************
lblProductCount.Text = "Products " & (intStartRow + 1).ToString & " - " & (intStartRow + intMaxRecords + 1).ToString & " of " & intProductCount.ToString
End Sub