Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Sorting datagrids

Hi i am using datagrids in a vb front end to a sql database and the customer wants to be able to click on a column and sort the data by that column. Is there an easy way to do this or will have to do it by keep changing the SQL query behind the datagrid

Cheers
0
davoman
Asked:
davoman
  • 2
  • 2
1 Solution
 
happelCommented:
What type of datagrid are you using?
Many grids allow you to set a sort-property (or multiple sorts) at runtime.
0
 
davomanAuthor Commented:
hi it literally is the vb datagrid that is wat it is called
0
 
happelCommented:
Sorry, I can find any way of sorting this grid.
The VB help gives the following example:

Private Sub DataGrid1_HeadClick (ColIndex As Integer)
   Data1.RecordSource = "Select * From Publishers Order By " & _
    DataGrid1.Columns(ColIndex).DataField
   Data1.Refresh
End Sub

Very, very, very basic functionality...

0
 
SteinerCommented:
If you don't want to use SQL each time you change sorting, you could use a recordset as source for your Datagrid.
Then just use:
MyRecordset.Sort = "name of field"
0
 
davomanAuthor Commented:
mite be basic but suits the needs of little old me.
Thanks for all the help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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