Asp. NET about data deletion issues on pagination

Source: Internet
Author: User
Tags execution stack trace
Asp.net| Page | data | Problem when you delete data on the last page, the situation is when you delete all the data from the last page, and then there are

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" 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

The reason is currentpageindex==pagecount!

The hint here is CurrentPageIndex must be >=0 and Pagecount<pagecount.

So the solution is to change the current CurrentPageIndex value, set it to 0 (the first page) or any value less than PageCount. I tried the following methods to solve the problem without success:

Datagrid1.pagecount=1; Here PageCount is not to be changed!!!

Datagrid1.currentpageindex-=1; First-1

/*if (datagrid1.pagecount-datagrid1.currentpageindex>1)

{datagrid1.currentpageindex+=1; }*/

If they are judged to be eligible again +1, because CurrentPageIndex must be less than PageCount, so first-1, but this method is not implemented, May be after the execution of the Delete this action will immediately check the value of CurrentPageIndex and PageCount, if not meet the criteria will throw an exception, will not give the following statement to execute the opportunity!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.