
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.OleDb
Imports System.Data
Imports Telerik.Web.UI

Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            RadGrid1.DataSourceID = "AccessDataSource1"
            RadGrid1.MasterTableView.DataKeyNames = New String() {"CustomerID"}
            RadGrid1.Width = Unit.Percentage(98)
            RadGrid1.PageSize = 5
            RadGrid1.AllowPaging = True
            RadGrid1.AllowSorting = True
            RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric
            RadGrid1.AutoGenerateColumns = False
            RadGrid1.Skin = "Web20"
            'Add Customers table
            RadGrid1.MasterTableView.PageSize = 15
            RadGrid1.MasterTableView.Width = Unit.Percentage(100)
            Dim boundColumn As GridBoundColumn
            boundColumn = New GridBoundColumn()
            RadGrid1.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "CustomerID"
            boundColumn.HeaderText = "CustomerID"
            boundColumn = New GridBoundColumn()
            RadGrid1.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ContactName"
            boundColumn.HeaderText = "Contact Name"
            'Add Orders table
            Dim tableViewOrders As New GridTableView(RadGrid1)
            RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders)
            tableViewOrders.DataSourceID = "AccessDataSource2"
            tableViewOrders.Width = Unit.Percentage(100)
            tableViewOrders.AllowPaging = True
            tableViewOrders.AllowSorting = True
            Dim relationFields As New GridRelationFields()
            tableViewOrders.ParentTableRelation.Add(relationFields)
            relationFields.MasterKeyField = "CustomerID"
            relationFields.DetailKeyField = "CustomerID"
            boundColumn = New GridBoundColumn()
            tableViewOrders.Columns.Add(boundColumn)
            boundColumn.DataField = "OrderID"
            boundColumn.HeaderText = "OrderID"
            boundColumn = New GridBoundColumn()
            tableViewOrders.Columns.Add(boundColumn)
            boundColumn.DataField = "OrderDate"
            boundColumn.HeaderText = "Date Ordered"
        End If
    End Sub
End Class

