how do I resort colums after databound grid refresh?

I know the column and the listsortdirection before I refresh the data in the grid, but the column only sorts ascending even when I tag it like the code below.
If _SortType = 0 Then
Me.dgSales(0, _SortCol).Tag = ListSortDirection.Ascending
Else
Me.dgSales(0, _SortCol).Tag = ListSortDirection.Descending
End If
dgSales.SortColumn(_SortCol). I'm using
Public WithEvents dgSales As GridHierDataBoundGrid as my grid.

thanks

1 Reply

AD Administrator Syncfusion Team November 28, 2006 04:58 AM UTC

Hi Prumery,

In DataBoundGrid, you can set these tag properties only through the Model.QueryCellInfo event handler. One way you can acheive this would be to set a flag in the your sort module and check this flag in order to enable the sorting icon for the header cell in the Model.QueryCellInfo.

//Or

You can use the DefaultView.Sort property of the underlying datasource in a grid to control the sort direction. Here is a code snippet to show this

DataTable dt = this.gridDataBoundGrid1.DataSource as DataTable;

//Ascending order.
//dt.DefaultView.Sort = "[ColumnName] ASC"; // or //dt.DefaultView.Sort = "[ColumnName]"

//descending order
//dt.DefaultView.Sort = "[ColumnName] DESC";

//Cancel the Sorting...
//dt.DefaultView.Sort = "";

this.gridDataBoundGrid1.Refresh();

Best Regards,
Haneef

Loader.
Up arrow icon