0

I am using Object Data Source to bind data in the gridview. I have set the property AllowSorting=true. While running the application, I could sort the data only in ascending order. Is there any way to achieve two way sorting in gridview ie. both ascending and descending on successive clicks ?.

Please give me a suggestion to solve this issue. Thanks in advance.

Victor
  • 4,721
  • 1
  • 26
  • 31
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
  • You need to store the sort direction and sort column in ViewState or Session for each grid, and then at the time you retrieve your datasource, apply the sort direction filter on it. Here's an article that explains it all: http://www.highoncoding.com/ArticleDetails.aspx?articleID=176 – Cᴏʀʏ Feb 02 '11 at 16:10
  • I cannot bind a DataSource manual, because I have a DataSourceID with the ID of the ObjectDataSource. If I kill the ID of the ObjectDataSource, I be not able to get the Delete-Method of the ObjectDataSource. – PassionateDeveloper Feb 02 '11 at 16:15
  • Your question has nothing to do with your problem. You dont say anything about binding or an issue with the DataSource. Please rewrite your question to reflect your problem. – Victor Feb 02 '11 at 16:18
  • And this is the 3rd question in a row you have asked about this http://stackoverflow.com/questions/4876660/asp-net-sorting-with-gridview-and-objectdatasource and here http://stackoverflow.com/questions/4876460/sorting-in-gridview-i-get-crazy – Victor Feb 02 '11 at 16:20
  • And? Nobody helps there, so I ask new questions until I get my answer – PassionateDeveloper Feb 02 '11 at 16:27

1 Answers1

0

there are many questions similar to this one.

here:

GridView sorting: SortDirection always Ascending

and here:

Gridview: capturing sort direction

and many more. please do a search

Community
  • 1
  • 1
Victor
  • 4,721
  • 1
  • 26
  • 31
  • @Kovu "Dont work for me" is not helpful. What have you tried? whats wrong with the answers attached? Include some code then. – Victor Feb 02 '11 at 16:12
  • I cannot bind a DataSource manual, because I have a DataSourceID with the ID of the ObjectDataSource. If I kill the ID of the ObjectDataSource, I be not able to get the Delete-Method of the ObjectDataSource. – PassionateDeveloper Feb 02 '11 at 16:16
  • Your question has nothing to do with your problem. You dont say anything about binding or an issue with the DataSource. Please rewrite your question to reflect your problem. – Victor Feb 02 '11 at 16:18