Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Finding max value in a dataview column

Posted on 2006-07-02
4
Medium Priority
?
2,418 Views
Last Modified: 2008-02-01
I have a dataview for which I want to find the max value of a column from multiple rows. Is there a method to do this without having to loop through one row at a time?

Thanks.
0
Comment
Question by:Mr_Fulano
[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
4 Comments
 
LVL 10

Accepted Solution

by:
ericwong27 earned 2000 total points
ID: 17029023

        ' Get the DefaultViewManager of a DataTable.
        Dim view As DataView = DataTable1.DefaultView

        ' Column sorted ascending.
        view.Sort = "NumberColumn DESC"
       
       ' The first row will be the max value
        Debug.WriteLine("Max : " & view(0)("NumberColumn").ToString)
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17029854
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17041056
hi


// C#

// The array rows will contain the row(s) that have the max value of SomeField. There could be more than one if two or more rows have the max value

DataRow[] rows = dataTable.Select("SomeField=Max(SomeField)");



// If you want to bind the result to a control then you can use a DataView

DataView view = new DataView(dataTable);

view.RowFilter = "SomeField=Max(SomeField)";

DataGrid.DataSource = view;

DataGrid.Bind();


this might help u : )






0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…

618 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