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

x
?
Solved

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

Posted on 2013-01-25
5
Medium Priority
?
302 Views
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
   
        Next
0
Comment
Question by:vbnetcoder
[X]
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
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
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


http://msdn.microsoft.com/en-GB/library/system.data.dataview.sort.aspx
0
 
LVL 7

Expert Comment

by:tipsybroom
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

0
 

Author Comment

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

Accepted Solution

by:
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)
0
 

Author Closing Comment

by:vbnetcoder
ID: 38835409
ty
0

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 (http://www.experts-exchange.com/M_6114203.html) 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