【问题标题】:Paged ObjectDataSource results in PageSize -1分页 ObjectDataSource 导致 PageSize -1
【发布时间】:2010-06-11 10:11:35
【问题描述】:

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

【问题讨论】:

    标签: asp.net listview asp.net-3.5 objectdatasource datapager


    【解决方案1】:

    通过修改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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多