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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

XGISCommented:
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
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks but not looking for a web forms DataGridView but rather a  ASP.net GridView
0
XGISCommented:
Hello murbro, the 1st example should be aspx.. the ms one was just for reference.

another link might help  VBASPNETGridView

else you could just call it from the markup properties
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.