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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:34:15+00:00 2026-06-10T07:34:15+00:00

I have a grid on a page which I want to be sortable on

  • 0

I have a grid on a page which I want to be sortable on multiple columns at the same time.

For example:

UserID        FirstName        LastName
=======================================
1             Bruce            Wayne
2             Peter            Parker
3             Clark            Kent
4             Tony             Stark
5             Helena           Wayne

The user can choose to order by LastName ASC then by FirstName DESC, which would produce the following:

UserID        FirstName        LastName
=======================================
3             Clark            Kent
2             Peter            Parker
4             Tony             Stark
5             Helena           Wayne
1             Bruce            Wayne

The user could reset the ordering and decide to order it in some other fashion.

How can I achieve this in LINQ? As far as I know, the way to chain ordering is to do something like

superheroes.OrderBy(x => x.LastName).ThenByDescending(x => x.FirstName)

Obviously, I don’t want to have to write out every possible combination of column orders (my grid may have up to 10 columns). Is there some way to make the ordering sequence dynamic?

  • 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-10T07:34:16+00:00Added an answer on June 10, 2026 at 7:34 am

    You need to use dynamic LINQ. Have a look at Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)

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

Sidebar

Related Questions

I have a Grid Panel, which when I leave the page, I want a
I have a page which contains a dynamically generated grid, where a user can
I have a grid view on my page and I want to export it
I have a grid made using slickgrid on a html page. I want to
I have page which is desgined for map point browsing. I want to show
I have one grid view which i want to add in footer of listview
I have a page which has a long grid/table data...I am testing it on
I have an ASPxGridView on my page which has a few columns of data.
I have a link which opens a table on the same page if user
I have to build a page which contains some text boxes and a grid

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.