By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

Datagrid causes error after page index changing

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
check for CurrentPageIndex in the code.
Are u setting the PageIndex somewhere ??

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"david" wrote:
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

Nov 19 '05 #2

P: n/a
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

"vinay" wrote:
check for CurrentPageIndex in the code.
Are u setting the PageIndex somewhere ??

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"david" wrote:
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

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.