2.0 Object Data Source -Sort

Posted on 2006-05-31
Last Modified: 2012-05-05
1st. Is the new object data easier for you guys? Its new to me, so its making my head hurt. I feel like its harder to use then the 1.1 sa, ds, and dv. (In regards to doing custom binding. aka I change data as it comes down from the sql server.)

But anyways on to the question at hand.

So, like I stated - I change data as I pull it from the SQL Server. Example, some things come down as 71206 and I would change that to 7/12/2006.
Thats all fine and great. In 2.0, I approach this by pointing my object DS to a function that returns a typed data set. And that works great. It binds to a grid view and theres my data. Now heres where I have the problem. And I bet this is an easy one. How in the world do I call the sort routine on the data. I want a default sort on the data. In 1.1 I would just through a dv in there and it would be done. I can't do this at the SQL level, nor do I want to do it in the function as then I would return a dv and there would go all my nice UI for the databound items. I know the 2.0 control can sort as I can do it via the gv as the app is running, but how do  I call it in the code behind? What am I missing. I want to use this data-sorted in a dropdownlist also, so sorting on the grid only would not work.

Question by:Jojo1771
    LVL 27

    Expert Comment

    This may help you with what you looking for.
    download the example to see the full source code
    Good luck
    LVL 96

    Expert Comment

    by:Bob Learned
    Download what example?

    LVL 5

    Author Comment

    A link to an example would be nice. But I have looked at almost every example in msdn, it seems like.

    To restate my question

    How do I sort the data in a Object Datasource, with out having to do a manual sort at the function level (aka passing the sort parameter)?
    LVL 33

    Accepted Solution

    I believe the answer is "You can't", the ObjectDataSource control doesn't actually sort the data unless you are returning a DataSet or DataTable, they just send the sort information you and databound controls send them to the underlying database, and that is actually what sorts the data.

    Check out what is said here about this, about halfway down the page,
    LVL 27

    Assisted Solution

    Sorry Jojo,
    I missed the most important thing in my post and that was the link

    LVL 5

    Author Comment

    I have read both of these sites already, and have finally given up and did the sort in my function like all the examples show. So i must agree with raterus and say its not possible.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    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…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    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

    7 Experts available now in Live!

    Get 1:1 Help Now