Getting total for a column in ListView
<p>I need to get a sum for all items in a column within a listview. I put in the following code in the itemdatabound event, but realized after testing it that it will only be getting what is bound, oops.</p>

<p>So I was looking for a little help converting this to show a total for my column from all items bound to the ListView.</p>

<p>Thanks.</p>

<pre><code> if (e.Item.ItemType == ListViewItemType.DataItem)     
       {
           ListViewDataItem item = (ListViewDataItem)e.Item;         

           Label lblQty = (Label)e.Item.FindControl("lblQuantity");
           if (lblQty == null)
           {
               return;
           }

           if (lblQty.Text.Length == 0 || lblQty.Text == "")
           {
               return;
           }
           else
           {
               ListViewTotal += int.Parse(lblQty.Text);
           }
       }
</code></pre>
