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
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