Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class DataGrid_DataDynamically
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        'Create DataTable object
        Dim myDataTable As New DataTable("Customers")
        myDataTable.Columns.Add(New DataColumn("CustomerID"))
        myDataTable.Columns.Add(New DataColumn("ContactName"))
        myDataTable.Columns.Add(New DataColumn("Address"))
        Dim rowValues(2) As Object

        'Row #1
        rowValues(0) = "ALFKI"
        rowValues(1) = "Maria Anders"
        rowValues(2) = "Obere Str. 57"
        myDataTable.Rows.Add(rowValues)

        'Row #2
        rowValues(0) = "AROUT"
        rowValues(1) = "Thomas Hardy"
        rowValues(2) = "120 Hanover Sq."
        myDataTable.Rows.Add(rowValues)

        'Set the data source
        myDataGrid.KeyFieldName = "CustomerID"
        myDataGrid.DataSource = myDataTable
        myDataGrid.DataBind()
    End Sub
End Class