sorting a gridview using a objectdatasource which is linked to a list of objects

Posted on 2008-11-14
Last Modified: 2012-05-05
Hi all.
Well Im going round in circles a bit here.
Im having problems trying to implement sorting with a gridview using an ObjectDataSource.

The ObjectDataSource is linked to a method which returns a list of objects.
The query in the method actually returns a DataSet but I am manually looping through the rows in the DataTable and creating objects sticking them in a list. This way the gridview knows the type of object its getting back and I get all the columns shown in the interface and can use the smart tag to setup the gridview.

This is all great until I have to implement sorting. Since its a list it doesnt support list but it says DataSet does. So I tried linking the object data source directly to the DataSet and even the DataTable but not only do i loose the columns sorting doesnt work.

So my question is really:
1) Is it not possible to sort gridviews with ObjectDataSources?
2) Is there no way just to link the gridview to a dataset and get all the nice smart tag features and columns setup for you?

Question by:osion
    LVL 9

    Accepted Solution

    You can sort a gridview using an objectDataSource but you'll have to write it.

    Its not so bad to write, the best example i could find is here:

    Author Comment

    Thanks amx,
    That seems good.
    All the best

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now