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. Datagrid Paging Button Count

Datagrid Paging Button Count

Scheduled Pinned Locked Moved ASP.NET
helpdatabasedesigntutorial
6 Posts 2 Posters 0 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.
  • T Offline
    T Offline
    Todd_S
    wrote on last edited by
    #1

    I have a datagrid that is bound to a dataset. I am having a problem getting the default paging to work properly. The page navigation buttons work for the first set of 10 pages. After selecting the "..." button to access the next set of 10 page buttons, when I select a new page button (for example, page 16), it takes me back to page 7. It is not indexing the page count & assuming that every page button count list is 0-10. Essentially, I can't view anything beyond page 10. Incidently, I tried setting the PagerStyle Mode="NextPrev" and I couldn't get past page 2 even though I kept selecting the ">" button. Here are my settings: AllowPaging=True; PageSize=10; PagerStyle Mode="Numeric Pages"; and PageButtonCount=10 Here is my code for the page index change event: Private Sub dgrdReport_PageIndexChanged(ByVal source As Object, _ ByVal e As System.Web.UI.Webcontrols.DataGridPageChangedEventArgs) _ Handles dgrdReport.PageIndexChanged Me.dgrdReport.CurrentPageIndex = e.NewPageIndex Me.dgrdReport.DataBind() End Sub Any suggestions on this issue would be appreciated. I have been struggling with this for a while now. Thanks.

    R 1 Reply Last reply
    0
    • T Todd_S

      I have a datagrid that is bound to a dataset. I am having a problem getting the default paging to work properly. The page navigation buttons work for the first set of 10 pages. After selecting the "..." button to access the next set of 10 page buttons, when I select a new page button (for example, page 16), it takes me back to page 7. It is not indexing the page count & assuming that every page button count list is 0-10. Essentially, I can't view anything beyond page 10. Incidently, I tried setting the PagerStyle Mode="NextPrev" and I couldn't get past page 2 even though I kept selecting the ">" button. Here are my settings: AllowPaging=True; PageSize=10; PagerStyle Mode="Numeric Pages"; and PageButtonCount=10 Here is my code for the page index change event: Private Sub dgrdReport_PageIndexChanged(ByVal source As Object, _ ByVal e As System.Web.UI.Webcontrols.DataGridPageChangedEventArgs) _ Handles dgrdReport.PageIndexChanged Me.dgrdReport.CurrentPageIndex = e.NewPageIndex Me.dgrdReport.DataBind() End Sub Any suggestions on this issue would be appreciated. I have been struggling with this for a while now. Thanks.

      R Offline
      R Offline
      R Senthil Kumaran
      wrote on last edited by
      #2

      Hi, Try Declare a viewstate and have it as 0 initially and when the 10 button is clicked increment it by 10, 20 ,30 so as..... in Page index change this is in Page index change! Me.dgrdReport.CurrentPageIndex = e.NewPageIndex + (int)viewstate("Paging") Me.dgrdReport.DataBind() actually this wont happen it automatically works i dont know the reason but try this! Loving Code, R. Senthil Kumaran

      T 1 Reply Last reply
      0
      • R R Senthil Kumaran

        Hi, Try Declare a viewstate and have it as 0 initially and when the 10 button is clicked increment it by 10, 20 ,30 so as..... in Page index change this is in Page index change! Me.dgrdReport.CurrentPageIndex = e.NewPageIndex + (int)viewstate("Paging") Me.dgrdReport.DataBind() actually this wont happen it automatically works i dont know the reason but try this! Loving Code, R. Senthil Kumaran

        T Offline
        T Offline
        Todd_S
        wrote on last edited by
        #3

        Thanks for your quick response. I did try something similar to this, but I could never get it to work properly. I will try your viewstate suggestion. I assume that I will also need to decrement the viewstate by 10, 20, 30 and so on whenever the back button is selected (that is, the "..." button that takes you to the previous set of 10 page buttons). One question, though ... where do I declare the viewstate = 0 initially? I can't have it in the page index change event. Thanks again.

        R 1 Reply Last reply
        0
        • T Todd_S

          Thanks for your quick response. I did try something similar to this, but I could never get it to work properly. I will try your viewstate suggestion. I assume that I will also need to decrement the viewstate by 10, 20, 30 and so on whenever the back button is selected (that is, the "..." button that takes you to the previous set of 10 page buttons). One question, though ... where do I declare the viewstate = 0 initially? I can't have it in the page index change event. Thanks again.

          R Offline
          R Offline
          R Senthil Kumaran
          wrote on last edited by
          #4

          Yes ofcourse u need to decrement it too.. and the initial declaration of the viewstate u can have inside postback of the page load !! do reply me the result! Loving Code, R. Senthil Kumaran

          T 1 Reply Last reply
          0
          • R R Senthil Kumaran

            Yes ofcourse u need to decrement it too.. and the initial declaration of the viewstate u can have inside postback of the page load !! do reply me the result! Loving Code, R. Senthil Kumaran

            T Offline
            T Offline
            Todd_S
            wrote on last edited by
            #5

            I was able to figure out what was going wrong. I was binding the datagrid every time the Page_Load event fired (at postback), instead of re-binding it on the PageIndexChanged event. I needed the following code in the Page_Load event: If Not Page.IsPostBack Then BindDataGrid() End If Also, I added the following code to the PageIndexChanged event: Dim dsReport As New DataSet Me.dgrdReport.CurrentPageIndex = e.NewPageIndex 'Re-bind the datagrid. dsReport = Session("dsReport") Me.dgrdReport.DataSource = dsReport.Tables("Report").DefaultView Me.dgrdReport.DataBind() Session("dsReport") = dsReport Thanks for your help. Sorry to take you on a tangent. But, it was helpful to discuss alternative methods for making this work.

            R 1 Reply Last reply
            0
            • T Todd_S

              I was able to figure out what was going wrong. I was binding the datagrid every time the Page_Load event fired (at postback), instead of re-binding it on the PageIndexChanged event. I needed the following code in the Page_Load event: If Not Page.IsPostBack Then BindDataGrid() End If Also, I added the following code to the PageIndexChanged event: Dim dsReport As New DataSet Me.dgrdReport.CurrentPageIndex = e.NewPageIndex 'Re-bind the datagrid. dsReport = Session("dsReport") Me.dgrdReport.DataSource = dsReport.Tables("Report").DefaultView Me.dgrdReport.DataBind() Session("dsReport") = dsReport Thanks for your help. Sorry to take you on a tangent. But, it was helpful to discuss alternative methods for making this work.

              R Offline
              R Offline
              R Senthil Kumaran
              wrote on last edited by
              #6

              Ohh yes!! its correct u need to write that inside the Postback! and i have a question to u why do u need the dataset in session Never try to load a dataset or a datatable in session it seems urs is a report so it may have more data. more and more data in session makes load to your server which results in a performance issue and i dont think it i srequired also in this scenario!! consider this!!:) Loving Code, R. Senthil Kumaran

              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