473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Datagrid causes error after page index changing

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
2 2099
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). This code doesn't even run unless a button in...
1
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to...
3
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using...
4
by: Luis Esteban Valencia | last post by:
I have a asp.net page (C#), with a datagrid. I use template for all columns, and have <asp:requiredfieldvalidator> in with one of the textboxes, to make sure it's filled in. However, this...
0
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). I have tried a few different notations...
1
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
6
by: slinky | last post by:
I found the following code to transfer datagrid data to an Excel file. Is this written in C#?... I'm a vb.netter. I'm just not sure where to place the code to experiment on it. Should I place it in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.