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

  • Home
  • SEARCH
  • 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 7953803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:14:28+00:00 2026-06-04T03:14:28+00:00

When you enable paging and sorting on MVC’s WebGrid, it automatically appends sort and

  • 0

When you enable paging and sorting on MVC’s WebGrid, it automatically appends sort and page parameters in the query string automatically. How does it do that? I understand how it creates a link for page n, but how does if read the query string to know what page to produce?

What really confuses me is that, in the controller, I don’t have to specify the page and sort parameters, but they work anyway. What manner of witchcraft is this?

in case I wasn’t clear enough,

here is the gridview definition

@{ var grid = new WebGrid(Model.Customers, rowsPerPage: 25, canPage: true }); }

here is the query string that is produced:

/Customer?sort=Notes&sortdir=ASC

and my Customer.Index controller

//no parameters here. how does WebGrid maintain querystring?
public ActionResult Index() 
{
    ...
}
  • 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-04T03:14:30+00:00Added an answer on June 4, 2026 at 3:14 am

    Long story short, it just plucks the values from HttpContext.Request.QueryString, which is not that magical afterall.

    For example, here’s where it accesses the sort field:

        public string SortColumn {
            get { 
                if (!_sortColumnSet) { 
                    string sortColumn = QueryString[SortFieldName];
                    // blah blah blah
                } 
                // blah blah blah
                return _sortColumn;
            } 
            set {
                // blah blah blah omitted for brevity
            } 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView that use a stored procedure for custom paging and sorting
I have datagrid with paging enabled that can have 10 rows per page. Also
I have a GridView in a page with paging enabled (sorting not enabled, not
i have a datalist that contains dynamic content. i need to enable paging to
I have a GridView webcontrol that has paging and sorting enabled. I've bound the
I have a GridView that uses LinqDataSource. The GridView has default paging enable. I
I'm using the android-viewflow library (https://github.com/pakerfeldt/android-viewflow) to enable horizontal paging. On each page, I
I have an ASP.NET GridView with paging enabled. The list of page indexes are
i've define static class to enable paging : public static class Pager { public
I have a UIScrollView with paging enabled, and that works fine. Now I want

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.