Solved

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

Posted on 2013-01-25
5
295 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
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
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
Comment Utility
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
Comment Utility
What is r in r.SalesAmountDescr?
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
Comment Utility
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
Comment Utility
ty
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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.…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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