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.
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
Post a Comment