Hi
My grid has a column which has a SUM aggregate being applied to it. This figure is being displayed correctly in the grid footer. I would like to be able to access this grid total in the code behind so i can display its value elsewhere on the page.
For a group footer you can access an aggregate field like so:
Protected Sub gridJourneys_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) If TypeOf e.Item Is GridGroupFooterItem Then
Dim item As GridGroupFooterItem = CType(e.Item, GridGroupFooterItem)
Dim groupDataRow As DataRowView = CType(e.Item.DataItem, DataRowView)
response.write (groupDataRow("Total"))
I tried this in a grid footer but it didn't work. I got the error Object reference not set to instance of object because the e.item.DataItem proeprty is null/nothing
ElseIf TypeOf e.Item Is GridFooterItem Then
Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
Dim gridDataRow As DataRowView = CType(e.Item.DataItem, DataRowView)
Throw New Exception(gridDataRow Is Nothing) <=========TRUE
How do I access the grid totals please?
I have already read this page in the help file
ms-help://telerik.aspnetajax.radcontrols.2008.Q3/telerik.aspnetajax.radgrid.2008.Q3/totals-in-grid-footers.html
In this method you have to find the total yourself by keeping a running total of the column in the itemdatabound event. I could do this but it does seem like a case of reinventing the wheel as the grid has obviously calculated the total and stored it somewhere. I just can't find it!
many thanks
My grid has a column which has a SUM aggregate being applied to it. This figure is being displayed correctly in the grid footer. I would like to be able to access this grid total in the code behind so i can display its value elsewhere on the page.
For a group footer you can access an aggregate field like so:
Protected Sub gridJourneys_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) If TypeOf e.Item Is GridGroupFooterItem Then
Dim item As GridGroupFooterItem = CType(e.Item, GridGroupFooterItem)
Dim groupDataRow As DataRowView = CType(e.Item.DataItem, DataRowView)
response.write (groupDataRow("Total"))
I tried this in a grid footer but it didn't work. I got the error Object reference not set to instance of object because the e.item.DataItem proeprty is null/nothing
ElseIf TypeOf e.Item Is GridFooterItem Then
Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
Dim gridDataRow As DataRowView = CType(e.Item.DataItem, DataRowView)
Throw New Exception(gridDataRow Is Nothing) <=========TRUE
How do I access the grid totals please?
I have already read this page in the help file
ms-help://telerik.aspnetajax.radcontrols.2008.Q3/telerik.aspnetajax.radgrid.2008.Q3/totals-in-grid-footers.html
In this method you have to find the total yourself by keeping a running total of the column in the itemdatabound event. I could do this but it does seem like a case of reinventing the wheel as the grid has obviously calculated the total and stored it somewhere. I just can't find it!
many thanks