• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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