Why is paging implemented so poorly?

mymnEntaita

New Member
After lots of time... I have figured out.. that the paging features of asp.net are crap. Hear me out for a sec. Lets say you need to page through 1000 records. You fill a dataset and display 10 records at a time using a datagrid. All 1000 records are brought into memory. Just to display 10 records. Ok so I do some research... I find out the DataAdapters fill method is overloaded and has the startRecords, maxRecords property. NICE!.. Except.. after further reading I found out even though the dataset only contains the records you want... The whole table still is returned to memory.. meaning the whole 1000 records still get returned.. just not into the datasets memory. Defeats the entire purpose. I dont like the datagrid. its hard for designers I work with to use. So im trying to inherit from the repeater class and add my own paging sorting functionality. So Whats next.. DataReader. Datareader is fast. But there is simply no way to page it. The only thing you can do.. is do a hack job on your sql statement... SELECT TOP 10 * FROM TABLE WHERE PKEYID > LASTKEY<BR><BR>Where lastkey was the primary key of the previous page. I dont like this solution. Even though it looks like thats where im going to be stuck.. And I wont be able to make my custom repeater. I figured out.. that the problem is with sql server and not the data objects. Its not the dataadapters fault or the DataReaders fault. In MySql there is a LIMIT command. You simply add it to the end of your sql statement LIMIT 40,60 This will return only records 40 - 60. If sql were capable of something like this then the dataobjects could use them.. The reason the data objects dont have reasonable paging methods ( internal or otherwise ).. is because sql server doesnt provide ways to page its data without doing some trippy hack job on your sql. Now.. Im stuck either returning all rows at once in a dataset and using a datagrid ( not going to happen ). Or spending hours on each repeater that I make.. (Got 10 or so custom forms to do).You could write your data into the cache and then pull the specific records you need out of it which is much faster then hitting the SQL Server everytime you page.A good book for you might be Dino Esposito's latest offering: <BR><BR> Building Web Solutions with ASP .NET and ADO .NET <BR> http://www.amazon.com/exec/obidos/ASIN/0735615780/forestlakewebser/ <BR><BR>Can I suggest that you buy it and read it; particularly the section on paging datagrids. He explains why the DataGrid works how it does with respect to paging and so forth.<BR><BR>Also, as an aside... have you looked into custom paging?Yes I have. Ive seen it for the datagrid with the datareader.. and seen some examples on how to do so. Its just a pain in the *** to do for every single one. Ive been trying to make my own repeater class that has its own paging. I couldnt figure out a way without using a dataset. And the dataset always gets filled up which is what im trying to avoid. The ultimate goal for me... was to be able to throw an sql statement into a datasource and have the repeater/datagrid figure out all the paging. But it really isnt possible to do it the way I want it. The other guy said cacheing.. probably the best solution.. Just use a dataset with caching.You are right... probably the best way to do it.. Just use a dataset and cache it. I would cache it anyways if possible. But still.. <BR><BR><rant><BR> Sql server should support some type of limit clause for paging. Other databases do it.. so should it. It should<BR>be built into ado. Paging is a common thing for data display.<BR></rant>
 
Back
Top