I have a RadFileExplorer in our application which is created dynamically. The grid has two bound columns for which we have to enable column sorting. I have registered the GridSortCommandEventHandler while creating the Grid but the grid is not triggering the Sort event.
radFileExplorer.Grid.ID = radGridViewName;
radFileExplorer.Grid.AllowSorting = true;
radFileExplorer.Grid.ItemDataBound += new GridItemEventHandler(radFileExplorer_ItemDataBound);
radFileExplorer.Grid.SortCommand += new GridSortCommandEventHandler(radFileExplorer_SortCommand);
radFileExplorer.TreeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);
Below is the code written for radFileExplorer_SortCommand event. The below event is not getting invoked on click of the column header.
void
radFileExplorer_SortCommand(object sender, GridSortCommandEventArgs e)
{
string sortDir = "ASC";
DataView dv = new DataView(Documents);
string viewStateKey = "sortDirection" + e.SortExpression;
if (ViewState[viewStateKey] != null)
{
sortDir = ((string)ViewState[viewStateKey] == "ASC") ? "DESC" : "ASC";
}
ViewState[viewStateKey] = sortDir;
dv.Sort = e.SortExpression +
" " + sortDir;
SortExpression = dv.Sort;
GridView docListGrid = (GridView)this.FindControl(radGridViewName);
if (docListGrid != null)
{
docListGrid.DataSource = dv;
docListGrid.DataBind();
}
}
This is quite urgent and any help would be appriciated.
Many thanks in advance.
Regards
Rajeev