R
Ross Culver
I get this error whenever a user clicks the 'last' page pager button on my
gridview. Below is the code behind the GridviewPageIndexChange
Dim ProviderCount As Integer = 0, PageNo As Integer = 0, PageCount As
Integer = 0, PageIdx As Integer = 0
Try
ProviderCount = TotalRecords()
PageIdx = Me.gvQuickSearch.PageIndex.ToString
PageNo = PageIdx + 1
PageCount = Me.gvQuickSearch.PageCount
Select Case ProviderCount
Case 0
Me.txtMessage.Text = "There were no providers in the ElephantBridge database
matching your keyword(s). Please double-check your spelling or try other
keywords. You can also use our Advance Search for more search assistance."
Me.txtPageResults.Text = Nothing
Case 1
Me.txtMessage.Text = "There is only " & ProviderCount & " provider in the
ElephantBridge database matching your selections."
Me.txtPageResults.Text = "Page 1 | Providers 1 of 1"
Case 2 To 11
Me.txtMessage.Text = "There are " & ProviderCount & " providers in the
ElephantBridge database matching your keyword(s)."
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-" & ProviderCount
& " of " & ProviderCount
Case 11 To 2000
Me.txtMessage.Text = "There are " & ProviderCount & " providers in the
ElephantBridge database matching your keyword(s)."
Select Case PageNo
Case 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-10 of " &
ProviderCount
Case 2 To PageCount - 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "-" & ((PageNo - 1) * 10) + 10 & " of " & ProviderCount
Case PageCount
Me.txtPageResults.Text = "Page " & PageCount & "| Providers " &
((PageCount - 1) * 10) + 1 & "-" & ProviderCount & " of " & ProviderCount
End Select
Case Is > 2000
Me.txtMessage.Text = "There are more than 2000 providers in the
ElephantBridge database matching your keyword(s). To narrow your search,
include additional keywords."
Select Case PageNo
Case 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-10 of 2000"
Case 2 To PageCount - 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "-" & ((PageNo - 1) * 10) + 10 & " of 2000"
Case PageCount
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "- 2000 of 2000"
End Select
Case Else
Me.txtMessage.Text = "There were no providers in the ElephantBridge database
matching your keyword(s). Please double-check your spelling or try other
keywords. You can also use our Advance Search for more search assistance."
Me.txtPageResults.Text = Nothing
End Select
At first I thought it was due to a datatype in my formula, but then I noted
that there's no error when I click the 'Next' pager button to page from the
next-to-last page to the last page, which uses the exact same line of code.
I'm sure the problem is with the gridview page index, but why would the
index be any different depending on whether you clicked the 'last' page
button versus the 'next' page button from the next-to-last page?
Thanks,
Ross
gridview. Below is the code behind the GridviewPageIndexChange
Dim ProviderCount As Integer = 0, PageNo As Integer = 0, PageCount As
Integer = 0, PageIdx As Integer = 0
Try
ProviderCount = TotalRecords()
PageIdx = Me.gvQuickSearch.PageIndex.ToString
PageNo = PageIdx + 1
PageCount = Me.gvQuickSearch.PageCount
Select Case ProviderCount
Case 0
Me.txtMessage.Text = "There were no providers in the ElephantBridge database
matching your keyword(s). Please double-check your spelling or try other
keywords. You can also use our Advance Search for more search assistance."
Me.txtPageResults.Text = Nothing
Case 1
Me.txtMessage.Text = "There is only " & ProviderCount & " provider in the
ElephantBridge database matching your selections."
Me.txtPageResults.Text = "Page 1 | Providers 1 of 1"
Case 2 To 11
Me.txtMessage.Text = "There are " & ProviderCount & " providers in the
ElephantBridge database matching your keyword(s)."
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-" & ProviderCount
& " of " & ProviderCount
Case 11 To 2000
Me.txtMessage.Text = "There are " & ProviderCount & " providers in the
ElephantBridge database matching your keyword(s)."
Select Case PageNo
Case 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-10 of " &
ProviderCount
Case 2 To PageCount - 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "-" & ((PageNo - 1) * 10) + 10 & " of " & ProviderCount
Case PageCount
Me.txtPageResults.Text = "Page " & PageCount & "| Providers " &
((PageCount - 1) * 10) + 1 & "-" & ProviderCount & " of " & ProviderCount
End Select
Case Is > 2000
Me.txtMessage.Text = "There are more than 2000 providers in the
ElephantBridge database matching your keyword(s). To narrow your search,
include additional keywords."
Select Case PageNo
Case 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers 1-10 of 2000"
Case 2 To PageCount - 1
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "-" & ((PageNo - 1) * 10) + 10 & " of 2000"
Case PageCount
Me.txtPageResults.Text = "Page " & PageNo & "| Providers " & ((PageNo - 1) *
10) + 1 & "- 2000 of 2000"
End Select
Case Else
Me.txtMessage.Text = "There were no providers in the ElephantBridge database
matching your keyword(s). Please double-check your spelling or try other
keywords. You can also use our Advance Search for more search assistance."
Me.txtPageResults.Text = Nothing
End Select
At first I thought it was due to a datatype in my formula, but then I noted
that there's no error when I click the 'Next' pager button to page from the
next-to-last page to the last page, which uses the exact same line of code.
I'm sure the problem is with the gridview page index, but why would the
index be any different depending on whether you clicked the 'last' page
button versus the 'next' page button from the next-to-last page?
Thanks,
Ross