我正在使用带有分页数据源的ListView。当ObjectDataSource尝试从“GetData”方法获取数据时,参数PageSize设置为-1,即使我已在DataPager中将PageSize设置为8。
我忘记了什么吗?
<asp:ListView DataSourceID="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>
答案 0 :(得分:0)
通过将ObjectDataSource修改为:
解决<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>