Click here to Skip to main content
16,004,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, I am looking to populate a listview with data from a db(already done) but once the list view is populated I would like to add up all the values in one column I thought it would be done something like:


foreach (FoodData item in FoodDataCollection)
                {
                    
                }


but I can't work out the code that would go inbetween, that is if that's the way todo it!!!


appreciate any help!
Posted
Updated 9-Sep-11 13:52pm
v2

1 solution

worked it out if it helps anyone else great!

foreach (FoodData item in FoodDataCollection)
                {
                    calories = Convert.ToInt16(item.Calories);
                    calorieTotal = calories + calorieTotal;
                }


hope someone finds it usefull!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900