I want to sort datagrid columns ascending or descending. They always sort ascending.
How can I do descending.
This is the code I have in the Sort Command event.
VB Code:
Private Sub dgrResults_SortCommand1(ByVal source As Object, ByVal e As _ System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgrResults.SortCommand Dim dstStudents As DataSet = PopulateGrid() ' Create a DataView from the Dataset. Dim dvwStudents As New DataView(dstStudents.Tables(0)) Try ' The DataView provides an easy way to sort. Simply set the ' Sort property with the name of the field to sort by. dvwStudents.Sort = e.SortExpression ' Rebind the data source and specify that it should be sorted ' by the field specified in the SortExpression property. dgrResults.DataSource = dvwStudents dgrResults.DataBind() Catch ex As Exception Response.Redirect(clsLib.RedirectTo(ex.Message, "Search.aspx")) End Try End Sub
The PopulateGrid function returns a dataset of data.




Reply With Quote