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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:02:46+00:00 2026-05-13T09:02:46+00:00

I have a problem with Gridview sorting that is similar to others but I’m

  • 0

I have a problem with Gridview sorting that is similar to others but I’m binding to a collection object as opposed to a data table.

The existing business rules and data access layers of an application follow the pattern of having an object and, if you need a collection of objects of that type, to have another class inheriting CollectionBase and implementing IBindingList.

For desktop applications, it was easy to databind a gridview to one of these objects and there weren’t any problems with turning on column sorting. Everything was ‘in state’ in the desktop app’s presentation layer.

Now that code is being moved to a new web application (ASP.NET 2.0, VB codebehind pages).

I’ve played around with what I had to do to only have certain columns of the collection show up in the gridview and the gridview looked pretty good. When I turned on ‘allow sorting’, that’s when the problems showed up.

I’m getting the error about not having a .Sorting method, etc. In researching this, I found all sorts of solutions that were easily implemented with dataviews if my source was a data table. But it’s not – it’s a collection. I tried to “cheap shot” a datasource by converting the collection to an XML memory stream and them trying to .ReadXML back into a dataset but that didn’t work [Root element is missing error was as far as I got in the dataset.ReadXml(ioTemp) where ioTemp was the System.IO.MemoryStream used in the xml serializer].

Because of the old desktop apps, I’ve never had to worry about sorting a collection since the gridview handled it once it was loaded. In fact, it’s a ‘standard’ that the collection’s .SortProperty, .SortDirection and .ApplySort all through NotSupportedExceptions (I inherited this code from programmers long gone).

Is there an easy way to convert the collection to a data table or a way to sort the collection without having to go back to the database each time? Object Data Sources won’t work becuase of the intricate rules in how the objects are built – the wizards in VS2005 just can’t handle what we need to do (grabbing data from several tables conditionally to make an object).

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-05-13T09:02:47+00:00Added an answer on May 13, 2026 at 9:02 am

    In the year since I originally asked this question, I managed to get a new ‘standard’ implemented so that collections of business objects were now generic lists.

    So now a “Collection class” that is little more than a “Inherits List(Of MyBusinessObject)” with a Sort Method that looks like this (performance wasn’t an issue):

    Public Overloads Sub Sort(ByVal strPropertyName As String, ByVal strDirection As String)
        Dim arSortedList As New ArrayList
        For Each item As MyBusinessObject In Me
            arSortedList.Add(item)
        Next
        arSortedList.Sort(New CaseInsensitiveComparer(Of MyBusinessObject)(strPropertyName, strDirection))
        For intI As Integer = 0 To arSortedList.Count - 1
            Item(intI) = arSortedList(intI)
        Next
    End Sub
    

    This seemed to work perfectly with the methodology used by the GridView for firing events.

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

Sidebar

Related Questions

No related questions found

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.