loop through datatable in ascending order

Posted on 2014-04-06
Last Modified: 2014-04-07
Hi experts
when I loop through datatable with the following code it starts at the top , but i would like to start at the bottom

for each row as datarow in dt.rows

Question by:b001

Expert Comment

ID: 39981527
try creating a recordset (based on a query) ordered DESC (or ASC) and, for each row in recordset

LVL 62

Expert Comment

by:Fernando Soto
ID: 39981564
Hi b001;

If you change your For Each loop as follows it will give you what you want.

For Each row As DataRow In dt.AsEnumerable().Reverse()
    ' ....

Open in new window

LVL 27

Accepted Solution

Ark earned 500 total points
ID: 39982052
For each r As DataRow In dt.Select("","SortColumnName DESC", _

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now