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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top