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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom /efficient paging and sorting gridview

Custom /efficient paging and sorting gridview

Scheduled Pinned Locked Moved ASP.NET
algorithmscsharplinqquestion
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.
  • M Offline
    M Offline
    mark_me
    wrote on last edited by
    #1

    Hi, Sorry, if this question is stupid but i have tried searching alot and couldn't find an exact answer. Also, i am not looking for an exact solution but guidance in the right direction would be highly appreciated. I realize that gridview paging selects all data but displays a portion of it. I want to implement custom paging where data is only specific data is selected. I have kind of done my homework on it. ie i can use linq to select and skip data, but i want page links to be displayed at the bottom of the page. Is there any property that sets this (i believe datagrid had virtualitemcount). Does gridview has something like this or do i need to program this portion. I would like to mention here that i don't want to use SqlDataSource or ObjectDataSource, rather i want to assign datatable to gridview.DataSource. Again, would i have to manage paging my self, if i implement above solution. Sorry, if its a stupid question. Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment. Thankyou very much

    N 1 Reply Last reply
    0
    • M mark_me

      Hi, Sorry, if this question is stupid but i have tried searching alot and couldn't find an exact answer. Also, i am not looking for an exact solution but guidance in the right direction would be highly appreciated. I realize that gridview paging selects all data but displays a portion of it. I want to implement custom paging where data is only specific data is selected. I have kind of done my homework on it. ie i can use linq to select and skip data, but i want page links to be displayed at the bottom of the page. Is there any property that sets this (i believe datagrid had virtualitemcount). Does gridview has something like this or do i need to program this portion. I would like to mention here that i don't want to use SqlDataSource or ObjectDataSource, rather i want to assign datatable to gridview.DataSource. Again, would i have to manage paging my self, if i implement above solution. Sorry, if its a stupid question. Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment. Thankyou very much

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      mark_me wrote:

      i can use linq to select and skip data

      I don't know anything about the problem domain you are working on and data structures you use. But if database is your persisting area, efficient way to do this is to get only rows that will be displayed.

      mark_me wrote:

      Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment.

      IMO, there is nothing wrong in using ObjectDataSource since it comes with inbuilt paging capabilities. If you are binding a DataTable, you need to set the TypeName property to DataTable. You need to provide two methods, one for selecting the data according to the page number and another method for calculating the total count of data. These methods should be assigned to SelectMethod and SelectCountMethod properties respectively. Scott Guthrie's article[^] gives an overview of doing this. He is using ASP.NET AJAX but the concepts are same. :)

      Navaneeth How to use google | Ask smart questions

      M 1 Reply Last reply
      0
      • N N a v a n e e t h

        mark_me wrote:

        i can use linq to select and skip data

        I don't know anything about the problem domain you are working on and data structures you use. But if database is your persisting area, efficient way to do this is to get only rows that will be displayed.

        mark_me wrote:

        Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment.

        IMO, there is nothing wrong in using ObjectDataSource since it comes with inbuilt paging capabilities. If you are binding a DataTable, you need to set the TypeName property to DataTable. You need to provide two methods, one for selecting the data according to the page number and another method for calculating the total count of data. These methods should be assigned to SelectMethod and SelectCountMethod properties respectively. Scott Guthrie's article[^] gives an overview of doing this. He is using ASP.NET AJAX but the concepts are same. :)

        Navaneeth How to use google | Ask smart questions

        M Offline
        M Offline
        mark_me
        wrote on last edited by
        #3

        Thankyou very much Navaneeth! I looked into the link that u have forwarded and seems like its the solution i was looking for. Thankyou. Actually, to be honest, i don't know why i didn't use sqldatasource. Probably, because i thought that maybe i will require a sqldatasource for each page and thought its better that i make one procedure and pass column names along with whereCondition and table name , and then use datasource=mytable. Though, initially it seemed a good idea but now i realize that probably, it was a bad idea. Anyways, I can get count of rows, but my problem is page links ie 1 2 3 4 ... at the bottom, Do i have to implement it manually or is there any property that would help me in a few lines of code. Thankyou,

        N 1 Reply Last reply
        0
        • M mark_me

          Thankyou very much Navaneeth! I looked into the link that u have forwarded and seems like its the solution i was looking for. Thankyou. Actually, to be honest, i don't know why i didn't use sqldatasource. Probably, because i thought that maybe i will require a sqldatasource for each page and thought its better that i make one procedure and pass column names along with whereCondition and table name , and then use datasource=mytable. Though, initially it seemed a good idea but now i realize that probably, it was a bad idea. Anyways, I can get count of rows, but my problem is page links ie 1 2 3 4 ... at the bottom, Do i have to implement it manually or is there any property that would help me in a few lines of code. Thankyou,

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          mark_me wrote:

          i don't know why i didn't use sqldatasource

          I was recommending ObjectDataSource not SqlDataSource. In fact, SqlDataSource is crap and should only be used for demonstration purpose.

          mark_me wrote:

          , Do i have to implement it manually or is there any property that would help me in a few lines of code.

          You don't have to implement it. See the article which I linked, he hasn't wrote extra code to display page numbers. Glad to hear that it helped. :)

          Navaneeth How to use google | Ask smart questions

          M 1 Reply Last reply
          0
          • N N a v a n e e t h

            mark_me wrote:

            i don't know why i didn't use sqldatasource

            I was recommending ObjectDataSource not SqlDataSource. In fact, SqlDataSource is crap and should only be used for demonstration purpose.

            mark_me wrote:

            , Do i have to implement it manually or is there any property that would help me in a few lines of code.

            You don't have to implement it. See the article which I linked, he hasn't wrote extra code to display page numbers. Glad to hear that it helped. :)

            Navaneeth How to use google | Ask smart questions

            M Offline
            M Offline
            mark_me
            wrote on last edited by
            #5

            Thanks, SqlDataSource is a crap! wow, thankyou, it was good to hear after i haven't used it. I will though, research on it a bit during the weekend. (for learning purposes) Yeah, after i replied and returned back to ur link, i realized that i replied a bit too soon. Thanks for pointing the direction. Thanks

            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