Click here to Skip to main content
15,892,298 members

Comments by Chris A Clarke (Top 2 by date)

Chris A Clarke 25-Mar-19 14:17pm View    
Ah ... WebControl ListItems have Text and Value string properties...

Using the foreach(ListItem str in ListBox1.Items)
{
Total += int.Parse(str.Value);
}

Or

Total = ListBox1.Items.Sum( c => Int.Parse(c.Value));
Chris A Clarke 25-Mar-19 14:10pm View    
Try initializing Total.

int Total = 0;

Then for fun try

var Total = ListBox1.Items.Cast<int>().Sum(); /// Textbox.Text = Total.ToString() or remove Total all together go to the TextBox.Text