I have repeater and it contains data. I want to sort the repeater by dropbox using jquery. Is it possible? If yes then how can I do it? Any example would be appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Yes it is possible - can you post the output of your repeater code (html), your "dropbox" and provide some information about where the data comes from and how you populate your repeater.
Johny12345Author Commented:
thanks for reply. Here is the detail:

Repeater looks like this in firefox browser

<span id="rptEmployee_ctl00_lblTitle">

    Employee 1


<span id="rptEmployee_ctl00_lblDescription">

    Employee desc




<span id="rptEmployee_ctl00_lblSalary">



Open in new window

code is like:

     string file = Server.MapPath("App_Data\\Salary.xml");
        XElement element = XElement.Load(file);

        var employees = from employee in element.Descendants("Employee")
                        select new
                            Title = employee.Element("Name").Value,
                            Description = employee.Element("Description").Value,
                            Salary = employee.Element("Salary").Value,

        rptEmployee.DataSource = employees;

Open in new window

Please advise. You can suggest me if I have loaded xml file in wrong way.

Julian HansenCommented:
Ok but what do you want to sort on?

Can you give an example of how the data comes out by default and how you want the sort to work.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Johny12345Author Commented:
sorry, I missed it. I have to sort salary.
Johny12345Author Commented:
What do u mean by default? Do you want me to post more from browser output?  The data is not in table structure.
Johny12345Author Commented:
Please sir, help me. If you need more info the let me know.. thx
Julian HansenCommented:
I still need to understand how your output looks - your post above shows 3 <span>'s all with different data. You say in your second last post you want to sort on salary - I am assuming that there are therefore other <span>'s that you have not shown?
Is each grouping of <span>'s inside a container? I am trying to visualise how your data looks on the screen and how you want to sort it?

Please post full output of your repeater before a sort and then describe how you want this to be sorted.
Johny12345Author Commented:
Ok, sir.

Here are then exact things,

How data looks:

How html in browser

Thanks lot
Johny12345Author Commented:
Sir, do u think, it is possible? please advise me
Julian HansenCommented:
Yes it is possible - I will post something back shortly.
Julian HansenCommented:
Are you able to modify the html code - specifically are you able to add classes to some of the elements that are in the ouptut?

A solution is possible without this but much simpler if you can add classes to certain elements.
Johny12345Author Commented:
Yes, of course. I can change html where needed.
Johny12345Author Commented:
I am still waiting!!, Please help
Julian HansenCommented:
Here is a sample on how to do this - some changes to your code needed to be made namely

1. A class added to the <label> that contains the price - this is not strictly necessary but does make the code a bit simpler.
2. Locating the table outside of the productListing <div>. If you want to be able to sort these items in browser then you need those items to be in their own container - not sharing it with another element that performs a different function.

A sample page is available here.

The source for this is attached.
Julian HansenCommented:
A final note - I had to change your sample code as the html you posted contained 11 items with the same price - which is not really useful in testing whether or not the sort function works.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Johny12345Author Commented:
Thank you sir, I appreciate.
Julian HansenCommented:
You are most welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.