Populate tfoot in ListView

D

DavidC

I have an aspx page with a ListView bound to a datasource. I added a tfoot
to the LayoutTemplate and it displays fine. However, I want to place a total
of data rows into a Label inside the tfoot. I am using the following code in
the code-behind page but it does not seem to be populating. Can anyone help?

Protected Sub lvTimesheets_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.ListViewItemEventArgs) Handles
lvTimesheets.ItemDataBound
Dim lbl As Label
If e.Item.ItemType = ListViewItemType.DataItem Then
'on a data row (not header/footer)
intTimesheetCount += 1
If Not e.Item.FindControl("LblWeek2Units") Is Nothing Then
lbl = CType(e.Item.FindControl("LblWeek2Units"), Label)
Dim curAmt As Double = Convert.ToDouble(lbl.Text)
If curAmt = 0 Then
dblTotalUnits += curAmt
End If
End If
Else
If Not e.Item.FindControl("LblTotalUnits") Is Nothing Then
lbl = CType(e.Item.FindControl("LblTotalUnits"), Label)
lbl.Text = dblTotalUnits.ToString
End If
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,736
Members
45,708
Latest member
RenaldoFor

Latest Threads

Top