Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list box that loads itself with numbers from the database table. Now I want to add up all the numbers being present in that drop down list. Can anyone give a hint how to add all those numbers?
Posted
Updated 24-Oct-10 7:17am
v2

1 solution

Sure!
1. Right a for loop across the items of the listbox
2. In each iteration, get the specific value for that index/item
3. Keep a track of those values in a variable. Keep a 'summ counter'
4. Once the loop is over, use the sum counter to show the value (add up of all existing numbers.)
 
Share this answer
 
Comments
Omar Akhtar 2009 24-Oct-10 13:17pm    
Sorry, I want to know how to to add the numbers in a dropdown list actually?
Sandeep Mewara 24-Oct-10 13:21pm    
Same thing!
Loop through ddlist.Items and sum them up.

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