Hello,

I have developed a site in VB.Net and ASP.Net with a database backend that allows a user to enter a centre code and in return it retrieves all records from the datbase where the centre code matches the one provide in the text box.

My list is appearing as required.

I have been given an additional requirement to "enable the user to click on a column and in return it sorts the data in the listbox in ascending or descending order.

For example, a user clicks on the 'Paper Title' column, and then the paper title with the letter earliest in the alphabet appears at the top, and if the user clicks again, the paper with the last letter in the alphabet appears.

Example: user clicks the column header and then 'Art' appears first.

The user clicks on the column again and then 'Science' appears first.

Is there a way to do this at all?

My data is retrieved from the database using a stored procedure.

If there is, can somebody advise??

Thanks,

Dan

This is one of those tasks that sound so simple but are not so simple when it comes down to it. Since you are posting on an ASP forum and say you have a 'site',we can safely assume that you have a web interface. In order to sort your recordset in different ways it is probably best to construct a new sql statement for each different order and re-create the recordset each time the user clicks a column heading (button or hyperlink). The problem with this is that it will necessarily have to re-load the whole web page. This may not be acceptable if there are any large files contained on the page.
It sounds like the user wants the features of a traditional stand-alone program in a web based interface.
I've probably not helped you very much but I may have given you some food for thought.

Hi mlesniak,

Yes, that is what I have done - a new order statement for every order direction and it works now.

Thank you :-)

Dan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.