Aaron,
If you look closely at the article "ViewCount" is declared as an
asp:boundcolumn. You have to use your own datacolumn name. This should be
the same name as the column you want totaled.
So if you had a query that went something like this: "SELECT ProductName,
ProductPrice FROM Products" you could do something like the following
assuming you have only two columns in your datagrid (bound automatically).
Private Sub FormatGrid(byval sender as object, byval e as
DataGridItemEventArgs) Handles MyGrid.ItemDataBound
Static Total as Decimal
Select Case e.Item.ItemType
Case = ListITemType.Alternating, ListItemType.Item
' Increment the total here - Remember this was declared as static so the
value will remain with each successive call
Total += Decimal.Parse(DataBinder.Eval(e.Item.DataItem, "ProductPrice"))
' OR another way
' Total += Decimal.Parse(CType(e.Item.DataItem,
System.Data.Common.DBDataRecord)("ProductPrice"))
Case = ListItemType.Footer
With e.Item
.Cells(0).HorizontalAlign = HorizontalAlign.Right
.Cells(0).Text = "Total:"
.Cells(1).Text = String.Format("{0:C}", Total)
End With
End Select
End Sub