Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-25
5
Medium Priority
?
304 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
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

963 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