[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2008-11-14
Medium Priority
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

Accepted Solution

amx earned 750 total points
ID: 22960064
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

ID: 22960156
Thanks amx,
That seems good.
All the best

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

872 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