I'm using linq to sql to get my data, when I set the page size on my data grid and the user selects page 2, I get a postback and I re-read all the data to show the second page. I suspect there should be a better way of doing this, a way that ends up reading just the data I need to show. I was wondering if there are any code samples...
You should really be looking at the Skip and Take methods.
See ScottGu's post on LINQ to SQL (Part 3), and search the page for "Paging our Query Results" - this has some nice examples.
Alternatively, if you use the LinqDataSource control, and you're talking to a SQL 2005 or 2008 database, you should get this behaviour automatically. LINQ to SQL (Part 5) covers that.
If you want really ease the database load, take a look at client-side paging...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With