Custom Serverside paging in GridView Vs DataGrid

All posts have moved to Typps

See you there.

Alessandro

12 Comments

  • >And lastly, we need to subscribe to PageIndexChanging event
    >of our GridView and pass the selected page index

    You don't need to do that for the GridView.

  • Raj, You are correct. Many thanks.

  • Sorry...scratch my original comment; I re-read your article, and it does talk about the ObjectDatasource, my bad.

  • Jason ;p

  • Uh... seriously??? THIS is the solution for custom paging with the GridView? This is completely ridiculous - it's no wonder .NET developers are becoming so disgruntled. .NET is becoming a declarative "magic-word" programming environment - STOP SCREWING STUFF UP!

  • I'm so glad to have invested my time in designing a data-access layer consisting of static methods only to find out that without an instance class I'll have to either rewrite my infrastructure code OR make two trips back to the database to retrieve the values and the selected count of the objects - did anyone on the ASP.NET team with ACTUAL knowledge of programming design this?

  • Hi, if you have not already, then try transforming your concrete class(the one with the actual method definitions, which is currently a static class) into an instance class instead and create a second singleton class whose sole purpose will be that of creating an instance of your concrete class and exposing the methods as static. This is also what is being adopted as per the provider model introduced in asp.net 2.0

    Good luck

  • yes ofcourse, your more than welcome. Btw, since you mentioned that you've written your own pager control, which is probably too late now however, in .net 3.5, there is a DataPager control.

    That might of been another good option for you. It never crossed my mind to mention it before. Might come in handy on another project maybe :

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx

  • LOL - no, I did NOT realize there was a DataPager control in .NET 3.5! I am usually pretty good about looking for things like that before I write my own, but didn't think about it in this case. I will take a look at the DataPager control - I did use the PagerSettings class in my Pager control, so I tried to reuse as much existing code as I could. Thanks again!

  • I was wondering if there is anyway of NOT using the object data source control and still having the Gridview to generate the page links for me in .NET 2.0.

  • I have used ObjectDataSource to do custom paging (ONLY REQUIRED if you have ZILLIONS Of records to page thru) and together with dynamic SQL in stored procedures and ObjectDataSource and calls using variable parameters as well as the records per page count and page number parameters...it really is arcane and ludicrously convoluted.
    BEST solution ?
    a) Index your database tables well
    b) Use the ROW_NUMBER construct in the called stored procedure
    c) Put gridview in a page or user control BUT without default pageing and call data access method directly
    d) Write your own pageing control - download the code
    from Apress (www.apress.com) book "C# E-Commerce" by Karli Watson" it has one that uses url to include page numbers and you only need one stored procedure.

  • Pager control only connects to ListView , otherwise you need to write an interface for otyer controls - why do Microsoft make life a pain like this? Check out Apress (www.apress.com)book "C# E-Commerce" and get source that shows how to create custom pager control using Repeater.

Comments have been disabled for this content.