
Partial Public Class RadGridWithTotalVB
    Inherits System.Web.UI.Page
    Private dataSource As New List(Of Product)() From { _
     New Product() With { _
      .UnitPrice = 20, _
      .ProductPrice = 12, _
      .Total = 0 _
     }, _
     New Product() With { _
      .UnitPrice = 20, _
      .ProductPrice = 12, _
      .Total = 0 _
     }, _
     New Product() With { _
      .UnitPrice = 20, _
      .ProductPrice = 12, _
      .Total = 0 _
     } _
    }

    Protected Sub Page_Load(sender As Object, e As EventArgs)

    End Sub

    Protected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
        Me.RadGrid1.DataSource = dataSource
    End Sub

    Protected Sub ButtonCalculate_Click(sender As Object, e As EventArgs)
        Dim unitPriceAsString As String = Me.TextBoxUnitPrice.Text
        Dim productPriceAsString As String = Me.TextBoxProductPrice.Text
        Dim unitPrice As Integer
        If Not Integer.TryParse(unitPriceAsString, unitPrice) Then
            Return
        End If
        Dim productPrice As Integer
        If Not Integer.TryParse(productPriceAsString, productPrice) Then
            Return
        End If
        Me.dataSource(0).UnitPrice = unitPrice
        Me.dataSource(0).ProductPrice = productPrice
        Me.RadGrid1.Rebind()
    End Sub

    Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
        Dim unitPriceAsString As String = Me.RadGrid1.MasterTableView.Items(0)("UnitPrice").Text
        Dim productPriceAsString As String = Me.RadGrid1.MasterTableView.Items(0)("ProductPrice").Text

        Me.TextBoxUnitPrice.Text = unitPriceAsString
        Me.TextBoxProductPrice.Text = productPriceAsString
        Dim unitPrice As Integer
        If Not Integer.TryParse(unitPriceAsString, unitPrice) Then
            Return
        End If
        Dim productPrice As Integer
        If Not Integer.TryParse(productPriceAsString, productPrice) Then
            Return
        End If
        Dim totalPrice As Integer = unitPrice + productPrice
        Me.TextBoxTotal.Text = totalPrice.ToString()
        Me.RadGrid1.MasterTableView.Items(0)("Total").Text = totalPrice.ToString()
    End Sub
End Class

Public Class Product
    Public Property UnitPrice() As Integer
        Get
            Return m_UnitPrice
        End Get
        Set(value As Integer)
            m_UnitPrice = Value
        End Set
    End Property
    Private m_UnitPrice As Integer
    Public Property ProductPrice() As Integer
        Get
            Return m_ProductPrice
        End Get
        Set(value As Integer)
            m_ProductPrice = Value
        End Set
    End Property
    Private m_ProductPrice As Integer
    Public Property Total() As Integer
        Get
            Return m_Total
        End Get
        Set(value As Integer)
            m_Total = Value
        End Set
    End Property
    Private m_Total As Integer
End Class
