Dim dg As DataGrid = sourceDim StrSort = dg.Attributes("SortExpression")Dim StrASC = dg.Attributes("SortASC")dg.Attributes("SortExpression") = e.SortExpressiondg.Attributes("SortASC") = "yes"If e.SortExpression = StrSort ThenIf StrASC = "yes" Then dg.Attributes("SortASC") = "no"Else dg.Attributes("SortASC") = "yes"End IfEnd If‘DataSetVar is the dataset variable which is populated with some dataDim dt As DataTable = DataSetVar.Tables(0)Dim dv As DataView = New DataView(dt)dv.Sort = dg.Attributes("SortExpression")If dg.Attributes("SortASC") = "no" Thendv.Sort &= " DESC"End Ifdg.CurrentPageIndex = 0dg.DataSource = dvdg.DataBind()
Dim dg As DataGrid = sourceDim dt As DataTable = Datasetvar.Tables(0)Dim dv As DataView = New DataView(dt)dg.CurrentPageIndex = e.NewPageIndexdv.Sort = dg.Attributes("SortExpression")If dg.Attributes("SortASC") = "no" Thendv.Sort &= " DESC"End Ifdg.DataSource = dvdg.DataBind()