Following Scott Mitchell's tutorial "Computing the Sum of a Column"
http://aspnet.4guysfromrolla.com/demos/dgExample28.aspx the value of
my summed columns are x2 (double up) upon first column sort command
(but remains at x2 on next column sorts)???
really strange!
Dim HR2_sum As Decimal = 0
Dim HR5_sum As Decimal = 0
Dim HR6_sum As Decimal = 0
Sub dg_ItemDataBound(ByVal sender As Object,
ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR2")) Then
Dim dHR2 As Decimal =
Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR2"))
HR2_sum += dHR2
End If
If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR5")) Then
Dim dHR5 As Decimal =
Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR5"))
HR5_sum += dHR5
End If
If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR6")) Then
Dim dHR6 As Decimal =
Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR6"))
HR6_sum += dHR6
End If
ElseIf e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(1).Text = "Totaler"
e.Item.Cells(2).Text = ""
e.Item.Cells(3).Text = ""
e.Item.Cells(4).Text = ""
e.Item.Cells(5).Text = ""
e.Item.Cells(6).Text = HR2_sum
e.Item.Cells(7).Text = HR5_sum
e.Item.Cells(8).Text = HR6_sum
End If
End Sub