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. gridview paging gridview not visible

gridview paging gridview not visible

Scheduled Pinned Locked Moved ASP.NET
csshelp
5 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.
  • H Offline
    H Offline
    haseeb_saeed
    wrote on last edited by
    #1

    Hi i have a grid and want to allow paging for my custom object stored in a list... the list has 1000 records and i want to show 50 per page... I did the following gridview.allowpaging=true; gridview.pagesize=50; gridview.datasource=mylist; currentlist=mylist; gridview.databind(); it works fine on the first time... when somebody clicks page 2, i called pageindexchanging event and added { grid1.PageIndex = e.NewPageIndex; grid1.DataSource = currentList; // grid1.DataSource=list grid1.DataBind(); } the grid isn't shown at all... i get an empty page... wat should i do; please provid help thanx in advance

    haseeb

    R 1 Reply Last reply
    0
    • H haseeb_saeed

      Hi i have a grid and want to allow paging for my custom object stored in a list... the list has 1000 records and i want to show 50 per page... I did the following gridview.allowpaging=true; gridview.pagesize=50; gridview.datasource=mylist; currentlist=mylist; gridview.databind(); it works fine on the first time... when somebody clicks page 2, i called pageindexchanging event and added { grid1.PageIndex = e.NewPageIndex; grid1.DataSource = currentList; // grid1.DataSource=list grid1.DataBind(); } the grid isn't shown at all... i get an empty page... wat should i do; please provid help thanx in advance

      haseeb

      R Offline
      R Offline
      Ryomin
      wrote on last edited by
      #2

      Check to ensure that there is data in your dataset. It could be that when you postback that your dataset is being wiped. Are you storing your currentList in the ViewState?

      Cheers Disgyza Programmer Analyst

      H 1 Reply Last reply
      0
      • R Ryomin

        Check to ensure that there is data in your dataset. It could be that when you postback that your dataset is being wiped. Are you storing your currentList in the ViewState?

        Cheers Disgyza Programmer Analyst

        H Offline
        H Offline
        haseeb_saeed
        wrote on last edited by
        #3

        yeah... ur right, my list becomes emptied up because of state issue, but my list is 2000 columns, storing that much data for every user , isn't that a bad idea? is viewstate created per user, each user will have own viewstate or do i have to save to someother place thanx...

        haseeb

        R 1 Reply Last reply
        0
        • H haseeb_saeed

          yeah... ur right, my list becomes emptied up because of state issue, but my list is 2000 columns, storing that much data for every user , isn't that a bad idea? is viewstate created per user, each user will have own viewstate or do i have to save to someother place thanx...

          haseeb

          R Offline
          R Offline
          Ryomin
          wrote on last edited by
          #4

          There are several ways you can do this, each have pro's and con's. 1. You can query the database and return your records for each time the event handler fires. This can be an issue on performance if you have a lot of records being returned. (multiply this by each user using the system). 2. You can set up special queries to return only a set amount of records (only the data grid's page size) this is a better approach because it returns only the records you want to show the user. 3. You can save the information to ViewState, the ViewState stores information about the page using the browsers memory. It has more of a performance hit on the client, instead of the server. My suggestion if there are a lot of records would be to use option 2. I'm sure there are quite a few more ways in which this can be accomplished... the easiest way would be to just query the database each time the event fires... but this has performance issues. Try it out and see what works best for your situation. Best of luck,

          Cheers Disgyza Programmer Analyst

          H 1 Reply Last reply
          0
          • R Ryomin

            There are several ways you can do this, each have pro's and con's. 1. You can query the database and return your records for each time the event handler fires. This can be an issue on performance if you have a lot of records being returned. (multiply this by each user using the system). 2. You can set up special queries to return only a set amount of records (only the data grid's page size) this is a better approach because it returns only the records you want to show the user. 3. You can save the information to ViewState, the ViewState stores information about the page using the browsers memory. It has more of a performance hit on the client, instead of the server. My suggestion if there are a lot of records would be to use option 2. I'm sure there are quite a few more ways in which this can be accomplished... the easiest way would be to just query the database each time the event fires... but this has performance issues. Try it out and see what works best for your situation. Best of luck,

            Cheers Disgyza Programmer Analyst

            H Offline
            H Offline
            haseeb_saeed
            wrote on last edited by
            #5

            thanx... for this beautiful answer... i think you are right,i should use option 2, gridview paging ... though , it is not gonna be that easy. and yeah... can u please help me one more thing, i am confused regarding view state, somebody told me that view state is not created for each user, so if ur using sessions, u should not be using viewstate... i thought each session has separate viewstate... thanx alot... take care

            haseeb

            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