Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Paging Problem with Data Grid

Paging Problem with Data Grid

Scheduled Pinned Locked Moved ASP.NET
helpcsharpcssasp-net
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imshally81
    wrote on last edited by
    #1

    Hi all, I am Showing some record in Data Grid, Data grid have also Edit and Delete Button, I also use Paging for Data Grid ( 10 Record per Data Grid). Problem is that, Suppose i have 11 record, and i am on Last page where only 1 record is showning, when i delete this last record,it gives the error "Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount in ASP.Net". I think it is Paging Error, but i not Resolve that..... Any Help is Highly appreciated.... Thanx in advance Sajjad

    M A 2 Replies Last reply
    0
    • I imshally81

      Hi all, I am Showing some record in Data Grid, Data grid have also Edit and Delete Button, I also use Paging for Data Grid ( 10 Record per Data Grid). Problem is that, Suppose i have 11 record, and i am on Last page where only 1 record is showning, when i delete this last record,it gives the error "Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount in ASP.Net". I think it is Paging Error, but i not Resolve that..... Any Help is Highly appreciated.... Thanx in advance Sajjad

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, After deleting the record, you also need to set the CurrentPageIndex property back to 0.

      I 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, After deleting the record, you also need to set the CurrentPageIndex property back to 0.

        I Offline
        I Offline
        imshally81
        wrote on last edited by
        #3

        We can't do this, because if we set the CurrentPageIndex property = 0 , so every deletion it goes back to First page.......

        M 1 Reply Last reply
        0
        • I imshally81

          We can't do this, because if we set the CurrentPageIndex property = 0 , so every deletion it goes back to First page.......

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Yeah, setting it to 0 is a simple way and also a lazy option. IMO, it all depends on what you need, then you can set it to the previous page after calculating the new page count or simply set it to a specific page like the first page.

          1 Reply Last reply
          0
          • I imshally81

            Hi all, I am Showing some record in Data Grid, Data grid have also Edit and Delete Button, I also use Paging for Data Grid ( 10 Record per Data Grid). Problem is that, Suppose i have 11 record, and i am on Last page where only 1 record is showning, when i delete this last record,it gives the error "Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount in ASP.Net". I think it is Paging Error, but i not Resolve that..... Any Help is Highly appreciated.... Thanx in advance Sajjad

            A Offline
            A Offline
            Alexandru Savescu
            wrote on last edited by
            #5

            In your delete method you must check to see if the item was the last on the page and then decrease the currentpageindex Regards, Alexandru Savescu

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups