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

how to access DataTable rows, as ordered by DefaultView?

I am not able to influence the construction of a certain DataTable.  To display it's contents, I set an "order by" clause into table1.DefaultView.Sort.  Everything is good in the gui (asp.net DataGrid), but I am having trouble accessing the records programmatically in that same sorted order.

Is there a way to actually sort the records in the DataTable?

Thanks for any help-
VS 2003
0
ottenm
Asked:
ottenm
  • 3
1 Solution
 
Elvio Lujan.Net Senior DeveloperCommented:
no the DefaultView is just a view!... to get the records ordered in the table you need to order in the source
0
 
ottenmAuthor Commented:
Then how to access the data using the view (so they come out sorted)?
0
 
ottenmAuthor Commented:

Found it, could also use for each:

        Dim v As DataView = table1.DefaultView
        While i < v.Count - 1
            Dim row As DataRowView = v.Item(i)
            Dim val As String = row("ColumnName")
            'etc.
        End While

0
 
ottenmAuthor Commented:
What's the right thing to do if you answer your own question?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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