473,410 Members | 1,857 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,410 software developers and data experts.

Datgrid currentPageIndex problem

Hello,

I am displaying data from database in datagrid. DG is having edit and
delete features. Pagesize is 10. I have total 12 records(2 pages). Now i am
deleting 12th and 11th records. Delete operation is successful. But, after
deleting the last record in the 2nd page, i am getting error " Invalid
CurrentPageIndex value. It must be >= 0 and < the PageCount." coz that is the
last record in that page but there are records in the prev page. What to do
to avoid that error?

May 2 '06 #1
1 1143
When you rebind the grid set the page index back ...

if(CurrentPage !=0 && (CurrentPageIndex + 1) * PageSize > TotalItems) {
CurrentPageIndex = TotalItems/PageSize - 1;
}

You can also subclass DataGrid and put it in the datagrid directly.

Cheers,

Greg

"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...
Hello,

I am displaying data from database in datagrid. DG is having edit and
delete features. Pagesize is 10. I have total 12 records(2 pages). Now i
am
deleting 12th and 11th records. Delete operation is successful. But, after
deleting the last record in the 2nd page, i am getting error " Invalid
CurrentPageIndex value. It must be >= 0 and < the PageCount." coz that is
the
last record in that page but there are records in the prev page. What to
do
to avoid that error?

May 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kelvin | last post by:
Hi all, I have to using 2 radiobuttons to control 2 datagrid summay and detail representively. when I click detail radionbutton, there are 10 pages records. when I click summary radiobutton, I...
0
by: Kelvin | last post by:
Hi all, I have to 2 radiobuttons to control 2 datagrid summay and detail representively. when I click detail radionbutton, In detail report 10 pages records. In the summary report just only 1...
1
by: Kelvin | last post by:
Hi All, I try to use the following microsft resolution web site, but still have same problem. http://support.microsoft.com/default.aspx?scid=kb;en-us;555074 I put the source code on...
0
by: jm | last post by:
I get this error when I click one of the datagrids pages: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. It is not doing this on the submit as I have this: Sub...
1
by: CW | last post by:
Is this by design or is it a bug? If you have a pageable datagrid. After you delete a row from the grid (which results in a reduction in the number of pages of the datagrid), asp.net throws an...
0
by: JackO | last post by:
I can't seem to find a good example of how someone resolved the currentpageindex error that occurs when I try and page to another page on my datagrid. My subroutine is: Private Sub...
0
by: JackO | last post by:
I am still stuck trying to resolve the CurrentPageIndex problem. I have 3 pages in my datagrid and when I try to go to the second page, I get the error. I modified my code to: Private Sub...
3
by: Franck | last post by:
Hello, in a datagrid, in the ItemDataBound event in some cells a add some javascript that show up an information strHref.Append("<A onclick=\"popupValid();\">"); strHref.Append("<span...
2
by: 1980dinesh | last post by:
Hi, I have a DatGrid and i have added a checkboxes as template column i have write javascipt code to check and unckeck but at button event of code behind i can't grab the (checked) true condition...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.