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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:57:27+00:00 2026-06-16T12:57:27+00:00

I am trying to use paging with grid. The following method gives everything in

  • 0

I am trying to use paging with grid. The following method gives everything in the table to the grid. How do I account for start and limit where start is the page number and limit is the records per page. Basically extjs toolbar looks for my method to return start and limit on demand. I have tried so many solutions but just can’t seem to work. That’s why I am putting this out here in the simple way.

this is my c# end

public string myRecord(int start, int limit)
{
    List<gridPaging> result = new List<gridPaging>();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices2"].ConnectionString))
    {
        SqlCommand cmd = con.CreateCommand();

        cmd.CommandText = "SELECT * FROM myTable ORDER BY Q1";
        con.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        while (reader.Read())
        {
            gridPaging gp = new gridPaging();

            gp.Column1 = reader["Column1"].ToString().Trim();
            gp.Column2 = reader["Column2"].ToString().Trim();
            gp.Column3 = reader["Column3"].ToString().Trim();
            gp.Column4 = reader["Column4"].ToString().Trim();
            result.Add(gp);
        }

        return JsonConvert.SerializeObject(result);
    }
}
  • 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-16T12:57:28+00:00Added an answer on June 16, 2026 at 12:57 pm

    In T-SQL, you have two built-ins that help you here; the first is the Row_Number function, which assigns a unique, increasing ordinal to each row of a result set as ordered by a special ORDER BY clause, and the second is the TOP keyword, which limits the maximum number of rows to be returned.

    Basically, your query should look like this:

    SELECT TOP @limit * FROM myTable WHERE (ROW_NUMBER() OVER (ORDER BY Q1)) > @limit * @start ORDER BY Q1
    

    You then plug in values for the parameters @start and @limit from your C# code using Command.CreateParameter. For, say, the third page of results (using a zero-indexed start value of 2) with 15 results per page, this evaluates to the statement

    SELECT TOP 15 * FROM myTable WHERE (ROW_NUMBER() OVER (ORDER BY Q1)) > 30 ORDER BY Q1
    

    … which provides rows from the overall query from 31 to 45, the first two pages’ queries having produced rows 1-15 and 16-30 respectively.

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

Sidebar

Related Questions

I'm trying to use Kendo-UI to manage a grid on a page, however I'm
I am trying to use the ObjectDataSource with enabled paging. This requires me to
i'm trying use facebook API to upload photo in my fan page. I downloaded
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I'm trying to use a DataPager to do Server Side paging. Here is my
I am trying to use data paging (not custom data paging - just normal
I'm trying to use url_rewrite to work around nonfriendly parameters in URL of paging
I am trying to find the best method for displaying data in a paging
I'm trying to use a PivotControlPage to control the paging of an object with

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.