Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8296649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:06:17+00:00 2026-06-08T15:06:17+00:00

When I try to connect together an ObjectDataSource, a ListView and a DataPager, the

  • 0

When I try to connect together an ObjectDataSource, a ListView and a DataPager, the correct values are not passed to the select method of the ObjectDataSource. -1 is always passed for maximumRows and 0 is passed for startRowIndex.

<asp:DataPager runat="server" ID="Address_DataPager" PageSize="50" PagedControlID="Address_ListView" >
    <Fields>
        <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true"
            FirstPageText="|&lt;&lt; " LastPageText=" &gt;&gt;|"
            NextPageText=" &gt; " PreviousPageText=" &lt; " />
    </Fields>
</asp:DataPager>
<asp:ListView ID="Address_ListView" runat="server"
    DataSourceID="Address_DataSource" DataKeyNames="AddressId" >
    <LayoutTemplate>
        <table class="resultsGrid">
            <tr class="gridRow">
                <th scope="col">Address</th>
            </tr>
            <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr class="gridRow">
            <td>
                <asp:Label ID="Address_Label" runat="server" Text='<%# Eval("Address") %>' />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="Address_DataSource" runat="server" TypeName="SuperApp.Business.Address"
    SelectMethod="SelectAddress" EnablePaging="True"
    MaximumRowsParameterName="maximumRows"
    StartRowIndexParameterName="startRowIndex" >
    <SelectParameters>
        <asp:Parameter Name="maximumRows"   DefaultValue="10" Type="Int32" />
        <asp:Parameter Name="startRowIndex" DefaultValue="5"  Type="Int32" />
    </SelectParameters>
</asp:ObjectDataSource>

This is the select method in the Address class in the SuperApp.Business namespace:

System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
public DataTable SelectAddress(int maximumRows, int startRowIndex)
{
    if (maximumRows < 1) throw new ArgumentOutOfRangeException("maximumRows", "Maximum rows should be greater than zero.");
    if (startRowIndex < 0) throw new ArgumentOutOfRangeException("startRowIndex", "Start row index should be greater or equal to zero.");
    if (startRowIndex >= maximumRows) throw new ArgumentOutOfRangeException("startRowIndex", "Start row index should be less than the maximum rows.");

    // Would do something interesting here.
    return null;
}

The first exception is always thrown, as maximumRows is always -1. I have tried:

  • Moving the DataPager into the LayoutTemplate.
  • Moving the DataPager into the LayoutTemplate and removing the PagedControlID value.
  • Changing the DefaultValue values to all sorts of things.
  • Removing the DefaultValues from the Parameters.
  • Removing the Type from the Parameters.
  • Removing the SelectParameters completely.

It is probably something obvious that I just can’t see. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:06:19+00:00Added an answer on June 8, 2026 at 3:06 pm

    Yes, this should be obvious.

    You lack the SelectCountMethod on your ObjectDataSource so that not only the current page can be selected but also it is possible to determine how many objects are there.

    A working example:

    http://netpl.blogspot.com/2009/04/how-to-controll-aspnet-listview-page.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try connect to SVN Repository and get SvnRepositoryIOException : Could not resolve hostname:
I try to connect to my BD This is my code public class JavaSQLTest
When I try to connect to local ports, Computer -> Connect local , using
When I try to connect Weblogic t3s protocol in Solaris Server, it shows this
What are the differences if I try to connect to an https using HttpURLConnection
First I unplug my network cable. Then I try to connect to SQL Server
I got mysql database in the phpmyadmin, and i try to connect to the
Ubuntu 12.04 has an open bug regarding openssl. If you try to connect to
Im having some trouble with an oracle database. Every time i try to connect,
Edit: Solved. Hi, I'm starting with Qt, I try to connect a slot to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.