This is a migrated thread and some comments may be shown as answers.

[Solved] Get Grid Sort Column and Direction

1 Answer 517 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 23 Jun 2009, 09:01 PM
I am currently working on a grid that is using the virtual scrolling, and I need to be able to determine, on post back, what the sort column and direction are. What properties of the radgrid can I use to get the current sort column and direction? I need to be able to access these values on post backs other than ones that fire the: RadGrid1_SortCommand event.

Something like:
if(IsPostBack)
{
string sSortColumn = RadGrid1.SortColumnName;
}

how do you return the column name?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jun 2009, 06:03 AM
Hello Jim,

You can try out the following code to access the sorted field name and the sort order of the mastertableview on postbacks:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        if (RadGrid1.MasterTableView.SortExpressions.Count != 0) 
        { 
            string name = RadGrid1.MasterTableView.SortExpressions[0].FieldName; 
            GridSortOrder order = RadGrid1.MasterTableView.SortExpressions[0].SortOrder; 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Jim
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or