Arithmetic Overflow Error When Click 'Last' Page Button

Discussion in 'ASP .Net Web Controls' started by Ross Culver, Aug 23, 2007.

  1. Ross Culver

    Ross Culver Guest

    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
     
    Ross Culver, Aug 23, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    881
    Purvi T
    Oct 19, 2004
  2. Amy
    Replies:
    0
    Views:
    1,011
  3. dlamoris
    Replies:
    0
    Views:
    896
    dlamoris
    Oct 26, 2006
  4. joshc
    Replies:
    5
    Views:
    576
    Keith Thompson
    Mar 31, 2005
  5. darrel
    Replies:
    4
    Views:
    841
    darrel
    Jul 19, 2007
Loading...

Share This Page