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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:25:54+00:00 2026-06-11T00:25:54+00:00

I am trying to sort a gridview in visual basic using the following method,

  • 0

I am trying to sort a gridview in visual basic using the following method, however the second line of code (Dim dv as DataView…) throws a NullReferenceException. When I debug the code and step through it, I can see that the DataTable dt has a value of “Nothing” after it is instantiated. Any help would be greatly appreciated.

        Dim dt As DataTable = grdExpProd.DataSource
        Dim dv As DataView = dt.DefaultView

        If (blnExTraining) Then
            dv.Sort = "ExpirationDate DESC"
        Else
            dv.Sort = "ExpirationDate ASC"
        End If

        grdExpProd.DataSource = dv
        grdExpProd.DataBind()
  • 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-11T00:25:55+00:00Added an answer on June 11, 2026 at 12:25 am

    After postback the DataSource of any Web-Databound-Control like GridView is Nothing (null in C#). Note that HTTP is stateless, all objects that are created in a page’s life-cycle will be destroyed as soon as the page was rendered.

    So the solution is easy, select the DataSource again with the correct ORDER BY.

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

Sidebar

Related Questions

I am using a Telerik GridView , and having an issue trying to sort
I'm trying to build a sort of Accordion effect using a GridView and UpdatePanels.
I'm trying to sort a list of entities using a GridView in ASP.NET, but
I am trying to code a sort routine against a dynamicaly populated gridview names
Trying to sort an array by writing my own sort method using recursion (Pine's
I am trying to sort a Vector list using the Java Collections frameworks. This
I am trying to sort a bunch of objects that have sort order, however
I am trying to sort an array of integers in MIPS using bubble sort
I am trying to sort a list of records that have been created using
I'm trying to sort a gridview with my objectdatasource which uses a function import

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.