Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


For Each objRow In Workspace.DataTable.DataSet - Order by

Posted on 2013-01-25
Medium Priority
Last Modified: 2013-01-30
In the following code how would I do this so it orders by SalesAmountDescr?

For Each objRow In Workspace.DataTable.DataSet
                    Text = objRow.SalesAmountDescr
Question by:vbnetcoder
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 83

Expert Comment

ID: 38820736
You can sort using the DataView object of the datatable. Looks like you have some poor naming conventions in use. Is DataSet of type DataTable? You can use DataTable.DefaultView.Sort property

Expert Comment

ID: 38820764
you can sort your rowcollection with linq

// create a sorted collection
var result = Workspace.DataTable.DataSet.OrderBy(r => r.SalesAmountDescr);

foreach (var item in result) Console.WriteLine(r.SalesAmountDescr);

Open in new window


Author Comment

ID: 38827399
What is r in r.SalesAmountDescr?
LVL 28

Accepted Solution

Ark earned 2000 total points
ID: 38829863
r is lambda function. VB syntax is almost similar to C# in all cases except of LINQ :). So, VB:
Dim result = Workspace.DataTable.DataSet.OrderBy(Function(r) r.SalesAmountDescr)

Author Closing Comment

ID: 38835409

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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