2010-06-11 49 views
0

我使用帶分頁數據源的ListView。當ObjectDataSource嘗試從「GetData」方法獲取數據時,即使我已經在DataPager中將PageSize設置爲8,PageSize被設置爲-1。分頁的ObjectDataSource結果在頁面大小-1

我忘記了什麼嗎?

<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

通過修改該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>