Search

DataPager double binds when paging using QueryStringField by ryanrr

Closed
as Fixed Help for as Fixed

12
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 355348
Opened: 7/8/2008 4:32:35 AM
Access Restriction: Public
1
Workaround(s)
4
User(s) can reproduce this bug
When you use the QueryStringField with a DataPager it causes the ListView to bind twice; once as if it was on the first page, and a second time for whatever page is passed via the QueryString (even if it is also the first page). Naturally, this is very bad for performance and completely unnecessary.
Details (expand)
Product Language
English

Version

.NET Framework 3.5
Operating System
Windows Server 2003
Operating System Language
English
Steps to Reproduce

Page Source:

<asp:ListView ID="lvItems" runat="server" ItemPlaceholderID="phItems" DataSourceID="odsItems">
<EmptyDataTemplate>
Sorry, no items were found that meet your criteria.
</EmptyDataTemplate>
<LayoutTemplate>
<asp:DataPager ID="pagerTop" runat="server" PageSize="2" PagedControlId="lvItems" QueryStringField="page">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
<asp:PlaceHolder ID="phItems" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<div><%#Eval("Title")%></div>
</ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="odsItems" runat="server" TypeName="TestItem" SelectMethod="GetItems" SelectCountMethod="GetItemsCount" EnablePaging="true" StartRowIndexParameterName="startIndex" MaximumRowsParameterName="maxRows">
</asp:ObjectDataSource>

Test Class:

Imports System.Collections.Generic

Public Class TestItem
Private _title As String
Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
_title = value
End Set
End Property

Public Shared Function GetItemsCount() As Integer
Return 5
End Function

Public Shared Function GetItems(ByVal startIndex As Integer, ByVal maxRows As Integer) As List(Of TestItem)
HttpContext.Current.Trace.Warn(String.Format("Getting Items : {0} - {1}", startIndex, maxRows))
Dim list As New List(Of TestItem)
With list
.Add(New TestItem With {.Title = "One"})
.Add(New TestItem With {.Title = "Two"})
.Add(New TestItem With {.Title = "Three"})
.Add(New TestItem With {.Title = "Four"})
.Add(New TestItem With {.Title = "Five"})
End With
Return list
End Function
End Class

Turn tracing on for the page and then use the datapager to navigate to a page... you'll see the "Getting items: X - X" output twice. You can also add event hooks for the ListView_ItemDataBound event and see that they fire as well. If you remove the QueryStringField parameter everything works correctly, using PostBacks of course.
Actual Results
Two binds/fetches of data. The first one being for the first page of data, the second bind being for the requested page of data.
Expected Results
Single bind/fetch of data.
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 7/9/2008 at 4:25 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Posted by Code Munkee on 7/29/2008 at 9:03 AM
I'd really like to see this fixed a.s.a.p.
Posted by philwith on 10/20/2008 at 4:13 AM
Has this been resolved then? If so how?
Posted by ljwagerfield on 6/19/2009 at 2:32 AM
Has this been fixed?! What is the work-around / fix? Please tell!!!
Posted by Microsoft on 7/1/2009 at 9:53 AM
We have fixed this issue in the next release of the .NET Framework. You can preview the fix in Beta 1 of .NET 4.
Posted by ljwagerfield on 7/24/2009 at 1:47 AM
I have written my own lightweight DataPager. It only support QueryStrings, but that's what you're after, right?

Download the Crucible .NET Project, and compile it (VS 2008)...
http://www.crucible.org.uk/ (Download it from the Crucible NET SVN, there's a link on the homepage).

The web control you're after is:
Crucible.NET.Web.UI.WebControls.QsDataPager

Behaves in the same way as DataPager... you can have it either inside your ListView, or outside with the PagedControlID property pointing to the ListView.
Posted by EnderII on 12/15/2009 at 3:30 PM
Can this fix not be added to a .Net 3.5 Service Pack?