Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Sort GridView by clicking on header

Hi

I am using the following code to populate a GridView in my ASP.net web page.
Is it possible to set up the GridView so that it sorts by a column when the header
of that column is clicked on?    

Sub Fill_GridView1(ByVal sSQL As String)

        Try
            ''Dim xSQLAdapter_Search As SqlDataAdapter
            ''Dim xSQLTable_Search As New DataTable
            xSQLTable.Clear()
            Dim cs As String = "Server=xxxxxxxxx.co.za;Database=xxxxxxxx"
            Dim connection As New SqlConnection(cs)
            xSQLAdapter = New SqlDataAdapter(sSQL, connection)
            xSQLAdapter.Fill(xSQLTable)
            Me.GridView1.DataSource = xSQLTable
            Me.GridView1.DataBind()

        Catch ex As Exception
            MsgBox(ex.Message & " 051h")
        End Try
    End Sub
Avatar of XGIS
XGIS
Flag of Australia image

Hello murbro;;;
please check the code samples on this page. There are at least 2 options available to you here.

manual-sorting-for-gridview

MS also have a sample..
headermouseclick
Avatar of Murray Brown

ASKER

Thanks but not looking for a web forms DataGridView but rather a  ASP.net GridView
ASKER CERTIFIED SOLUTION
Avatar of XGIS
XGIS
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much