First, you'll need to define a global variable to hold the value to be displayed in the footer.
Public ClmTotChg As Integer = 0
Public ClmTotBal As Integer = 0
Then, you'll need to populate the variable. This is where it gets tricky. In order for this to work, you must set the “DataMember“ property of the MasterTableView or DetailTableView for the footer you want a total in. You'll also need to set the ShowFooter value to true. For instance...
<
MasterTableView DataMember="CLAIM" DataKeyNames="CLMNO" ShowFooter="True">
Next, you will need to populate the variable when a detail item is added to the grid. You will do this in the “ItemDataBound“ event on the grid.
'The following is used to update the total fields for the footer on the Claim Header grid
If TypeOf e.Item Is GridDataItem And e.Item.OwnerTableView.DataMember = "CLAIM" Then
Dim gridItem As GridDataItem = CType(e.Item, GridDataItem)
Select Case gridItem.ItemType
Case GridItemType.AlternatingItem, GridItemType.Item
ClmTotChg += gridItem("CLMAMT").Text
ClmTotBal += gridItem("CLMBAL").Text
End Select
End If
Finally, you'll need to add the totals to the footer.
'The following is used to add a footer to the Claim Header grid that will show the totals
If TypeOf e.Item Is GridFooterItem And e.Item.OwnerTableView.DataMember = "CLAIM" Then
Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
footerItem("CLMAMT").Text = Format$(ClmTotChg, "$#,###,##0.00")
footerItem("CLMBAL").Text = Format$(ClmTotBal, "$#,###,##0.00")
End If
That's all there is to it.