Paged ObjectDataSource results in PageSize -1
I'm using a ListView with a Paged DataSource. When the ObjectDataSource tries to fetch data from the "GetData"-method, the parameter PageSize is set to -1, even though I have set the PageSize to 8 in the DataPager.
Have I forgotten something?
<asp:ListView DataSour开发者_开发知识库ceID="odsProductIndex" ID="lstProductIndex" runat="server" OnItemDataBound="lstProductIndex_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
<div class="Clear"></div>
<div id="Pagination">
<asp:DataPager ID="pagProductIndex" PageSize="8" runat="server" PagedControlID="lstProductIndex">
<Fields>
<asp:NextPreviousPagerField ButtonType="Image" ShowLastPageButton="false" ShowNextPageButton="false" PreviousPageImageUrl="~/Images/LexiconWord/Icons/pagination_previous.png" />
<asp:NumericPagerField ButtonCount="10" PreviousPageText="..." NextPageText="..." />
<asp:NextPreviousPagerField ButtonType="Image" ShowFirstPageButton="false" ShowPreviousPageButton="false" NextPageImageUrl="~/Images/LexiconWord/Icons/pagination_next.png" />
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
<ItemTemplate>
<!-- ITEM TEMPLATE HERE -->
</ItemTemplate>
<EmptyDataTemplate>
No products found...
</EmptyDataTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="odsProductIndex" runat="server"
EnablePaging="true"
SelectMethod="GetData">
</asp:ObjectDataSource>
Resolved by modifying the ObjectDataSource to:
<asp:ObjectDataSource ID="odsProductIndex"
runat="server"
EnablePaging="true"
MaximumRowsParameterName="maximumRows"
StartRowIndexParameterName="startRowIndex"
SelectMethod="GetData">
<SelectParameters>
<asp:Parameter Name="maximumRows" DefaultValue="8" />
<asp:Parameter Name="startRowIndex" DefaultValue="0" />
</SelectParameters>
</asp:ObjectDataSource>
精彩评论