Imports Telerik.Web.UI
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page

 
    Protected Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs)
        Dim table As New DataTable()
        table.Columns.Add("ID")
        table.Columns.Add("Item")
        table.Columns.Add("ItemInteger", GetType(Integer))
        table.Columns.Add("Date", GetType(DateTime))
        For i As Integer = 1 To 100
            table.Rows.Add(i, "Item" & i.ToString(), i + 10, DateTime.Now.AddDays(i))
        Next
        RadGrid1.DataSource = table
    End Sub

    Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
        Dim footer As GridFooterItem = CType(RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0), GridFooterItem)
        Dim itemsCount As Integer = RadGrid1.MasterTableView.Items.Count
        Dim item1 As GridDataItem = CType(RadGrid1.MasterTableView.Items(itemsCount - 1), GridDataItem)
        Dim item2 As GridDataItem = CType(RadGrid1.MasterTableView.Items(itemsCount - 2), GridDataItem)

        footer("ItemInteger").Text = (CType(item1.GetDataKeyValue("ItemInteger").ToString(), Integer) + CType(item2.GetDataKeyValue("ItemInteger").ToString(), Integer)).ToString()
    End Sub
End Class
