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 139731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:29:16+00:00 2026-05-11T07:29:16+00:00

I’m trying to figure out ASP.NET’s GridView pagination mechanics so I can use the

  • 0

I’m trying to figure out ASP.NET’s GridView pagination mechanics so I can use the framework’s native functionality instead of my company’s home-brewed manual pagination routines which take a lot of work to implement.

I’ve figured out everything except how get the GridView‘s PageCount property to work with our web services. Currently, our web services return the total record count like the following:

public object[] GetStuffMethod(int pageNum, int recordsPerPage, out int totalRecords) 

This works fine with a GridView, however the documentation I’ve found says that the GrideView‘s PageCount property is generated from the total records in the DataSource. Is there really no way to set the PageCount based on something else other than returning all of the records?

There could be tens of thousands of records in my data source so I’d rather not select all of them just to make the GridView’s page count work. I probably could just ignore the GridView’s page count and calculate it on my own, but if the framework has a way to do this, I’d rather use it.

  • 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. 2026-05-11T07:29:16+00:00Added an answer on May 11, 2026 at 7:29 am

    I strongly recommend that you go the ObjectDataSource route.

    If you are unfamiliar with this approach here are the basics:

    1) Instead of manually setting the grid.DataSource property in the code behind, you add an extra element to the page . You set the DataSourceID of the grid to the id of your ObjectDataSource.

    2) This is where you get real control. You create a new class and give it two functions ‘SelectRows()’ and ‘GetCount()’. You can put your logic in both functions and optimize to your heart’s content. Feel free to use web services if that’s what you need to work with, but under this method, you can call one to return rows and other to return the count.

    3) use the ObjectDataSource’s property editor to connect it to your class and enable paging. You’re all set!

    I strongly suggest you check out The Code Project’s Example of using ObjectDataSource and GridView as this is clearly the intended way to support what you want.

    Good luck!

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

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Turned out that it was the line ob_start("ob_gzhandler"); that caused… May 11, 2026 at 8:48 am
  • added an answer I documented how I used Lucene.NET in my ASP.NET application… May 11, 2026 at 8:48 am
  • added an answer I'm almost certain that installing the current version of php… May 11, 2026 at 8:48 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.