Results 1 to 4 of 4

Thread: How to tell what column GridView is sorted on?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question How to tell what column GridView is sorted on?

    Hi Everyone,

    I have a gridview control connected to a sqldatasource control. I am allowing the user to sort the columns in the gridview control. The user can click a row and visit another page. When they return I need to set the column sort again. I have seen that I can use the Sorting event to set the sort order of the data when I return to the page in the Sorting event. But before I leave the page where can i get the column it is currently sorted on along with the direction?

    Thanks!

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: How to tell what column GridView is sorted on?

    Hey,

    In the Sorting event of the GridView, you should be able to use the SortExpression property of the GridViewSortEventArgs parameter to get information about which column is being sorted on. You could store this into a Session Variable, or somewhere similar, and then retrieve it when you come back to the page.

    http://msdn.microsoft.com/en-us/libr...eventargs.aspx

    Hope that helps!

    Gary

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Re: How to tell what column GridView is sorted on?

    Thanks. I can store it in a session variable. When I return to the page, I can't set a sort on the SQLDataSource control (connected to AS400). So would I put the data in somelike a dataview grid, sort it and then set the datasource of the gridview to the datavieew grid? Or is there a much better method to do this?

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: How to tell what column GridView is sorted on?

    Hello,

    I haven't tried this, but, am I not right in saying that there is a SortExpression on the GridView itself? Can you not set this when you return to the page, which should in turn then tell the SqlDataSource what data to return.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width