Sort GridView by clicking on header


I am using the following code to populate a GridView in my 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)

            ''Dim xSQLAdapter_Search As SqlDataAdapter
            ''Dim xSQLTable_Search As New DataTable
            Dim cs As String = ";Database=xxxxxxxx"
            Dim connection As New SqlConnection(cs)
            xSQLAdapter = New SqlDataAdapter(sSQL, connection)
            Me.GridView1.DataSource = xSQLTable

        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.

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


MS also have a sample..
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks but not looking for a web forms DataGridView but rather a GridView
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

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
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.