asp.net - ListView Running total -


i have listview , calculate running total of values. every dataitem have bound listview, has "amount". on listview1_itemdatabound, data item's "amount" value, cannot find how access item.

this kind of similar, think, except want running total, not total @ end.

displaying totals in listview layouttemplate

you should able find item in dataitem inside listviewitem. sample code might like:

public int listviewtotal {  get; set; }    protected void mylistview_itemdatabound(object sender, listviewitemeventargs e)   {     if (e.item.itemtype == listviewitemtype.dataitem)     {       // retrieve underlying data item. in example       // underlying data item datarowview object.               datarowview rowview = (datarowview)dataitem.dataitem;        listviewtotal += rowview["amount"];        //set text of listview control new total:       label lbl = (label)e.item.findcontrol("myamountlabel");       lbl.text = listviewtotal.tostring();     }   } 

hope helps point in right direction.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -