Link to home
Start Free TrialLog in
Avatar of AWestEng
AWestEngFlag for Sweden

asked on

Get all data from a column in a datagridview

Hi..

How do I get all data from a column in a datagridview
I want to calulate the total amount in one column
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think that AWestEng just wants the total in a variable!
Hi,

you can use the DataColumn.Expression Property which also provide aggregation and sum's collumns

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

if you're working with DataTables, you can perform aggregate function over its rows. For example, table.Compute("sum(price)", "") would calculate the sum on all rows over price column in your DataTable.

as shown here

dim myvalue as Object
myvalue = dsSale.Tables("Grid").Compute("Sum(columnToBeCalulated)", "")

should give the total(sum of all rows) in that column.


vbturbo
Avatar of AWestEng

ASKER

thx guys.. :)
ops I was to fast vbturbo:, did not see you message sorry.
No problem

Just glad you solved it -:)