views:

984

answers:

2

Hi,

I have a web app(ASP.NET 2.0 with C#), and in it I have a gridview that gets its data from an oracle database.

I needed to implement the sort function for the gridview, so I added a dropdownmenu right above the gridview with 2 choices: Ascending and Descending. Then in the Gridview_Sorting method, I have a switch statement that basically checks the selection on the dropdown menu, and sorts accordingly.

This works, but I want to be able to click it once, and it sorts one way, then click it again, and it sorts the other way. Another thing I'd like to have would be images beside the column names that tell you which direction the data is sorted in.

Any suggestions? Thank you.

+1  A: 

A simple solution would be to use an image control or image button. On the click event, toggle the image from 1 image to the other. To determine previous state, either use a session variable or determine what the image button's imageurl property was previously set to, toggle it and call your sort method.

asp316
+1  A: 

Check out this blog post for a generic subroutine to handle this

Josh Stodola