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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:55:45+00:00 2026-06-10T21:55:45+00:00

I have an ASP.NET page and it’s associated Handler class. I would like to

  • 0

I have an ASP.NET page and it’s associated Handler class. I would like to limit the amount of repetitious code within this handler. At the moment, I have a method that returns a DataTable containing data from two joined tables.

Public Shared Function GetAllRecords() As DataTable
        Dim dt As New DataTable

        Try
            Using context As New QREntities()
                Dim records = (From record In context.QRRecords
                          Join advert In context.QRAdvertisements On record.adId Equals advert.adId
                          Select record.recId, record.hitDate, record.hitLocation, record.ipAddress, advert.adRedirectUrl, advert.adType, advert.adData
                          Order By hitDate Descending).ToList()

                'Set the column headers and their accepted data types
                dt = SetDataTableColumns()

                For Each r In records
                    dt.Rows.Add(r.recId, r.hitDate, r.hitLocation, r.ipAddress, r.adRedirectUrl, r.adType, r.adData)
                Next
            End Using
        Catch ex As Exception
            Return Nothing
        End Try

        Return dt
    End Function

Now I would like to allow the individual to sort by any column they choose. I was considering passing a value as a parameter which is then checked in a select statement and the associated column is then used with the Order By but the issue with this is, Dim records is a List of an Anonymous Type which means I can’t declare it before hand that I am aware of. My question is to everyone, what would by the best way to accomplish this?

I have looked into Query Objects, Custom Expressions and Query sets but they seem to be leading me astray.

Thanks in advance!

  • 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-10T21:55:46+00:00Added an answer on June 10, 2026 at 9:55 pm

    Dynamic Linq Library OrderBy function allows for dynamic sorting of columns and direction.

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

Sidebar

Related Questions

I have this ASP.NET page which I would like to print. What I am
I have a asp.net page, and would like to know whether script1 is already
I have an asp.net page within which I've used several AJAX controls doing partial
I have an asp.net page with a c# code-behind. I am trying to have
I have an asp.net page with c# code-behind. I have an event that is
I have an asp.net page with a multiview control nested within another multiview control.
I have an ASP.NET page that uses a repeater nested within another repeater to
I have asp.net page like this: Default.aspx: <%@ Page Title=Home Page Language=C# MasterPageFile=~/Site.master AutoEventWireup=true
Within an asp.net web form I would like to add values back to a
I have an ASP.net page designed like this as shown below: <%@ Page Title=

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.