我有点困惑为什么这不起作用,我可能做错了什么。
我在 Amount 列中有一个带有值的转发器,我想在转发器的页脚中显示该列的总数。
问题是 Total 总是显示 0 而不是将行的值相加。
代码背后
Protected Sub reCosts_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles reCosts.ItemDataBound
Dim rowView As System.Data.DataRowView
rowView = CType(e.Item.DataItem, System.Data.DataRowView)
Dim CostsTotal As Decimal
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim lCostAmount As Literal = CType(e.Item.FindControl("lCostAmount"), Literal)
Dim CostAmount As Decimal = rowView("Amount")
lCostAmount.Text = CostAmount.ToString("C2")
CostsTotal += CostAmount
ElseIf e.Item.ItemType = ListItemType.Footer Then
Dim lCostsTotal As Literal = CType(e.Item.FindControl("lCostsTotal"), Literal)
lCostsTotal.Text = CostsTotal.ToString("C2")
End If
End Sub
任何帮助,将不胜感激。
J。