0

我正在使用带有分页数据源的 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>
4

1 回答 1

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>
于 2010-06-11T12:03:26.473 回答