[Webinar] Streamline your web hosting managementRegister Today

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

Help with sorting column is DataTable using vb.net

Hi,

I'm using the code below to search data in a DataTable, How do I sort the results by SN?

Dim SearchCriteria As String = "Substring(SN, 1,3) IN (" & xyz & " )"

                Dim FilteredDTA As DataTable
                Dim DVA As New DataView(dtsetLinkAOP6A.Tables(0), SearchCriteria, Nothing, DataViewRowState.CurrentRows)
                FilteredDTA = DVA.ToTable
                If FilteredDTA.Rows.Count > 0 Then

                    C1Screen1.Columns(0).Visible = True
                    Me.C1Screen1.DataSource = FilteredDTA.DefaultView.ToTable(True, New String() {"SN", "AGD", "CA"})
                    Me.C1Screen1.Columns("SN").Width = 60
                    Me.C1Screen1.Columns("AGD").Width = 500
                    Me.C1Screen1.Columns("CA").Width = 350
                Else
                    MsgBox("No Records Found")

                End If

Thanks,

Victor
0
vcharles
Asked:
vcharles
1 Solution
 
Jacques Bourgeois (James Burger)PresidentCommented:
I di not test, but I would try sorting the DataView before using it to create a table.

DVA.Sort = "SN"
0
 
vcharlesAuthor Commented:
Hi,

Unfortunately it does not work.

Thanks,

Victor
0
 
käµfm³d 👽Commented:
Looking at the documentation for the Sort property, I suspect you need to add either "ASC" or "DESC" in addition to the column name.

e.g.

DVA.Sort = "SN ASC"

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
CodeCruiserCommented:
Could it be problem related to you trying to sort numeric values in a string column?
0
 
vcharlesAuthor Commented:
Thank You.
0
 
vcharlesAuthor Commented:
It worked with DVA.Sort = "SN ASC".

Thanks,

V.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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