Published Monday, October 22, 2007 1:11 AM by martin

Unanswered Question from ASP.NET 3.5 Event

In my ASP.NET 3.5 sessions last week, the same question was asked in two different venues.  It relates to the demo where I show the three new controls...

<asp:ListView>

<asp:LinqDataSource>

<asp:DataPager>

When I use the DataPager to paginate results shown in the ListView, coming through the LinqDataSource, does it query the database for one page at a time, or does it still get the entire contents of the database...?

I just ran the demo with the SQL Profiler attached, and I can confirm that it fetches the data one page at a time.  This is achieved through a T-SQL query that uses the ROW_NUMBER() function.  If I skip straight to page 5, it doesn't have to load pages 1 to 4 first.  I think that's the way we all hoped it would work.