Protected Sub gvList_Sorting(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) _ Handles gvList.Sorting hfSortField.Value = e.SortExpression hfSortDirection.Value = e.SortDirection LoadData() End Sub
Private Sub LoadData() Try Dim Sql As String ' Here you may extract records from any ' table from your database. Sql = "Select * From Users " & _ " Order By " & hfSortField.Value & " " & _ hfSortDirection.Value Dim dt As DataTable dt = GetDataTable(Sql) ' These following code is importat to bind ' the records to the Grid View. gvlist.DataSource = dt gvlist.DataBind() Catch ex As Exception ShowError(ex) End Try End Sub