Datagrid causes error after page index changing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Problem:
There is a search button, Search, in form, for searching patient info list.
The error occurs after the following steps:
1. search first time is OK, and all found the records are displayed in the
datagrid by using databind().
2. After the first-time search, I navigate the pages by clicking the page
changing arrow < or > which defined in datagrid design (of course, the page
index is chaning).
3. After the the page index changed, I clicked the search button to search
again by filling searching keys, then got the folling error in the line about
databind.

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
--------
Exception Details: System.Web.HttpException: Invalid CurrentPageIndex value.
It must be >= 0 and < the PageCount.

Source Error:


Line 976: dgRegPatient.DataSource = dsRegPats
Line 977: dgRegPatient.DataKeyField = "RegKey"
Line 978: dgRegPatient.DataBind()
Line 979: lblInfo.ForeColor = System.Drawing.Color.Green
Line 980: lblInfo.Text =
dsRegPats.Tables("RegPatients").Rows.Count & " patients found"



Source File: c:\inetpub\wwwroot\Demo\PatientRegister.aspx.vb Line: 978
--------------------------

Anyone can give me a help about it? and how to add code to fix the problem?

Thanks

David
 
did not set the page index.
For example, after I go to the next page and then search new data and bind
it to the datagrid, I got the error message.

However, If I just in the first page, I can search other data and bind it to
the datagrid without error.

DW
 
Back
Top