I read and tried to use the repeater paging method I found on 4 Guys from
Rolla (I've tried others also) but it doesn't seem to work. Please see the
code I have below and tell me what I may be doing wrong. I'm using Visual
Studio with SQL 2000. This is question/answer page that loads questions &
answers dynamically. I would like to present 1 question at a time instead of
all questions on one page as quizzes may have up to 50 questions. Can any
one help????
Imports System.Data.Ole Db
Imports System.Data
Public Property CurrentPage() As Integer
Get
' look for current page in ViewState
Dim o As Object = Me.ViewState("_ CurrentPage")
If o Is Nothing Then
Return 0 ' default to showing the first page
End If
End Get
Set(ByVal Value As Integer)
Me.ViewState("_ CurrentPage") = value
End Set
End Property
Private Sub ItemsGet()
' Read sample item info from XML document into a DataSet
Dim Items As New DataSet
Dim DBCommand As OleDbDataAdapte r
Dim DBConn As OleDbConnection
Dim objPds As New PagedDataSource
Dim I As Integer
Dim J As Integer
Dim TempID As String
'Connection string goes here.
DBCommand = New OleDbDataAdapte r _
("Select SectionQuestion ID, QuestionText " _
& "From SectionQuestion s Where CourseSectionID = " _
& Session("Course SectionID"), DBConn)
DBCommand.Fill( Items, "QuizQuestions" )
---->Problem 1:
'Data container loads selection from above query ("QuestionText" ) but not for
the other query on this page.
'Loads questions
For I = 0 To Items.Tables("Q uizQuestions"). Rows.Count - 1
Dim lcHTML = New LiteralControl
lcHTML.Text = "<b>
" _
& Items.Tables("Q uizQuestions"). Rows(I).Item("Q uestionText") & "</b>
"
TestRptr.Contro ls.Add(lcHTML)
Dim MyDDL = New RadioButtonList
TempID = Items.Tables("Q uizQuestions"). Rows(I).Item("S ectionQuestionI D")
MyDDL.ID = "Q" & TempID
DBCommand = New OleDbDataAdapte r _
("Select AnswerText " _
& "From QuestionAnswers Where SectionQuestion ID = " _
& TempID, DBConn)
DBCommand.Fill( Items, TempID)
---->Problem 2:
'Data Container does not recognize the above query and gives "not part of
QuizQuestions (first query on page) table" error when try to retrieve
AnswerText
'Loads Answers
For J = 0 To Items.Tables(Te mpID).Rows.Coun t - 1
Dim MyItem = New ListItem
MyItem.Text = Items.Tables(Te mpID).Rows(J).I tem("AnswerText ")
MyDDL.Items.Add (MyItem)
Next
TestRptr.Contro ls.Add(MyDDL)
Dim lcHTML2 = New LiteralControl
lcHTML2.Text = "
"
TestRptr.Contro ls.Add(lcHTML2)
Next
' Populates the repeater control with the Items DataSet
'Dim objPds As New PagedDataSource
objPds.DataSour ce = Items.Tables(0) .DefaultView
objPds.AllowPag ing = True
objPds.PageSize = 1
objPds.CurrentP ageIndex = CurrentPage
lblCurrentPage. Text = "Page: " + (CurrentPage + 1).ToString() + " of " +
objPds.PageCoun t.ToString()
' Disable Prev or Next buttons if necessary
PrevBtn.Enabled = Not objPds.IsFirstP age
NextBtn.Enabled = Not objPds.IsLastPa ge
TestRptr.DataSo urce = objPds
TestRptr.DataBi nd()
End Sub
Finally: The above code runs, the lblCurrenPage and Prev and Next buttons
appear as they should but do not move to next record(page). Also as mentioned
above only the QuestionText appears not the AnswerText. Help --- please!!!!!
--
Gracias in Advance!
Rolla (I've tried others also) but it doesn't seem to work. Please see the
code I have below and tell me what I may be doing wrong. I'm using Visual
Studio with SQL 2000. This is question/answer page that loads questions &
answers dynamically. I would like to present 1 question at a time instead of
all questions on one page as quizzes may have up to 50 questions. Can any
one help????
Imports System.Data.Ole Db
Imports System.Data
Public Property CurrentPage() As Integer
Get
' look for current page in ViewState
Dim o As Object = Me.ViewState("_ CurrentPage")
If o Is Nothing Then
Return 0 ' default to showing the first page
End If
End Get
Set(ByVal Value As Integer)
Me.ViewState("_ CurrentPage") = value
End Set
End Property
Private Sub ItemsGet()
' Read sample item info from XML document into a DataSet
Dim Items As New DataSet
Dim DBCommand As OleDbDataAdapte r
Dim DBConn As OleDbConnection
Dim objPds As New PagedDataSource
Dim I As Integer
Dim J As Integer
Dim TempID As String
'Connection string goes here.
DBCommand = New OleDbDataAdapte r _
("Select SectionQuestion ID, QuestionText " _
& "From SectionQuestion s Where CourseSectionID = " _
& Session("Course SectionID"), DBConn)
DBCommand.Fill( Items, "QuizQuestions" )
---->Problem 1:
'Data container loads selection from above query ("QuestionText" ) but not for
the other query on this page.
'Loads questions
For I = 0 To Items.Tables("Q uizQuestions"). Rows.Count - 1
Dim lcHTML = New LiteralControl
lcHTML.Text = "<b>
" _
& Items.Tables("Q uizQuestions"). Rows(I).Item("Q uestionText") & "</b>
"
TestRptr.Contro ls.Add(lcHTML)
Dim MyDDL = New RadioButtonList
TempID = Items.Tables("Q uizQuestions"). Rows(I).Item("S ectionQuestionI D")
MyDDL.ID = "Q" & TempID
DBCommand = New OleDbDataAdapte r _
("Select AnswerText " _
& "From QuestionAnswers Where SectionQuestion ID = " _
& TempID, DBConn)
DBCommand.Fill( Items, TempID)
---->Problem 2:
'Data Container does not recognize the above query and gives "not part of
QuizQuestions (first query on page) table" error when try to retrieve
AnswerText
'Loads Answers
For J = 0 To Items.Tables(Te mpID).Rows.Coun t - 1
Dim MyItem = New ListItem
MyItem.Text = Items.Tables(Te mpID).Rows(J).I tem("AnswerText ")
MyDDL.Items.Add (MyItem)
Next
TestRptr.Contro ls.Add(MyDDL)
Dim lcHTML2 = New LiteralControl
lcHTML2.Text = "
"
TestRptr.Contro ls.Add(lcHTML2)
Next
' Populates the repeater control with the Items DataSet
'Dim objPds As New PagedDataSource
objPds.DataSour ce = Items.Tables(0) .DefaultView
objPds.AllowPag ing = True
objPds.PageSize = 1
objPds.CurrentP ageIndex = CurrentPage
lblCurrentPage. Text = "Page: " + (CurrentPage + 1).ToString() + " of " +
objPds.PageCoun t.ToString()
' Disable Prev or Next buttons if necessary
PrevBtn.Enabled = Not objPds.IsFirstP age
NextBtn.Enabled = Not objPds.IsLastPa ge
TestRptr.DataSo urce = objPds
TestRptr.DataBi nd()
End Sub
Finally: The above code runs, the lblCurrenPage and Prev and Next buttons
appear as they should but do not move to next record(page). Also as mentioned
above only the QuestionText appears not the AnswerText. Help --- please!!!!!
--
Gracias in Advance!