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

SortCommand and Column UniqueName

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mahesh
Top achievements
Rank 1
mahesh asked on 02 Dec 2008, 10:37 AM
I need to access column uniquename in sortcommand event. Rightnow i am getting DataField name (through e.SortExpression) . But for some senario i want to get column unique name as well. Is the any way to do that.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 02 Dec 2008, 11:06 AM
Hello Mahesh,

You can find a code-snippet with a possible approach below:
protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e) 
    foreach(GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
        if (col is GridBoundColumn && (col as GridBoundColumn).DataField == e.SortExpression) 
            RadAjaxManager1.Alert(col.UniqueName); 

Protected Sub RadGrid1_SortCommand(ByVal source As ObjectByVal e As GridSortCommandEventArgs) 
    For Each col As GridColumn In RadGrid1.MasterTableView.RenderColumns 
        If TypeOf col Is GridBoundColumn AndAlso (TryCast(col, GridBoundColumn)).DataField = e.SortExpression Then 
            RadAjaxManager1.Alert(col.UniqueName) 
        End If 
    Next 
End Sub 

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
mahesh
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or