Datagrid causes error after page index changing

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
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top