0

I have a page that binds data from an EntityDataSource to a paged ASP.NET ListView. The query is actually a fairly complex query and I don't know that an EDS is really the way to go but it's inherited code and I am hoping to resolve this issue without having to re-engineer the page completely.

The problem is that when the page is Posted Back, with a filter parameter, the query executes once without the filter and then once again with the filter. The problem is that the unfiltered resultset is 17+ million records and times the request out.

So my question is ...

  1. Why is the query executing twice? I thought that it might have had something to do with the DataPager on the ListView but when I removed it from the page it didn't change anything.

Update: 2013/04/16

Thank you @bUKaneer and @lthibodeaux. I thought it would behelpful to add the request information to the OP.

As suggested, I commented out Pager control(s) and list view. Upon their removal all requests to the database stopped. I added back just the ListView and the query was executing twice again.

There are no additional event handlers assigned to the EDS itself.

<asp:EntityDataSource ID="edsSerialNumbers" runat="server" ContextTypeName="DBName.Entities" EnableFlattening="False" 
                      EntitySetName="DIST_TABLE" Include="PRODUCT, DISTRIBUTION, DISTRIBUTION.COMPANY_SITE" 
                      EnableUpdate ="true" EnableViewState="true"
                      OrderBy="it.DISTRIBUTION.DIST_NAME, it.PRODUCT.SERIAL_NUMBER"></asp:EntityDataSource>

The DataPager is actually embedded in a separate UserControl that is included outside of the ListView, and is included twice ...

<div class="dataTablePager">
    <kqp:TablePager ID="pgrTop" runat="server" PagedControlID="lvSerialNumbers"/>
</div>

 <asp:ListView ID="lvSerialNumbers" runat="server" DataKeyNames="ID" OnDataBound="lvSerialNumbers_DataBound" OnItemEditing ="lvSerialNumbers_ItemEditing" onitemdatabound="lvSerialNumbers_ItemDataBound" EnableViewState="true">
            ...

</asp:ListView>

<div class="dataTablePager">
    <kqp:TablePager ID="pgrBot" runat="server" PagedControlID="lvSerialNumbers"/>
</div>

The only place in the code behind that the EDS is touched is here in the PreRender phase...

protected void Page_PreRender(object sender, EventArgs e)
{
    if (!kqpFilters.IsFiltered && !IsPostBack)
    {
        lvSerialNumbers.DataSourceID = null;            
    }
    else
    {
        lvSerialNumbers.DataSourceID = "edsSerialNumbers";
    }
}
Gary O. Stenstrom
  • 2,284
  • 9
  • 38
  • 59
  • Is anything else binding to the EDS? If you comment out the ListView, the DataPager and the EDS does anything else break? – Luke Baughan Apr 15 '13 at 15:43
  • Without seeing a bit more of the code itself it's going to be difficult to determine exactly what's happening here. What event handlers are there on the data source? Is the data pager actually part of the list view's layout template, or if is it outside, is the PagedControlID value correctly set? Is the filter parameter being set on postback part of the EntityDataSource's parameter collection, or is something happening in code behind then forcing rebinding? – lsuarez Apr 15 '13 at 19:15

1 Answers1

0

After commenting EVERYTHING out except the spot where the ListView's datasource is assigned to the EDS I was unable to resolve this problem.

I will work around it by ripping out the EDS and replacing it it with a call to a stored procedure instead. Very frustrating though as this problem exists on about 10-15 screens and without an alternative I will have to re-write each, from the ground up.

Gary O. Stenstrom
  • 2,284
  • 9
  • 38
  • 59