• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

ASP.net Sort GridView by clicking on header


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)

            ''Dim xSQLAdapter_Search As SqlDataAdapter
            ''Dim xSQLTable_Search As New DataTable
            Dim cs As String = "Server=xxxxxxxxx.co.za;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 Brown
Murray Brown
  • 2
  • 2
1 Solution
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  ASP.net 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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now