
Imports System.Data
Imports Infragistics.Web.UI.GridControls

Partial Class _Default
    Inherits System.Web.UI.Page

    Dim random As Random = New Random()

    Public Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim dataTable As DataTable = GetDataSource()
        Me.WebDataGrid.DataSource = dataTable
        Me.DataBind()
    End Sub

    Private Function GetDataSource() As DataTable
        Dim dataTable = New DataTable()
        dataTable.Columns.Add("Id", GetType(Integer))
        dataTable.Columns.Add("Username", GetType(String))
        dataTable.Columns.Add("Color", GetType(String))
        dataTable.PrimaryKey = New DataColumn() {dataTable.Columns(0)}


        For i As Integer = 1 To 20
            Dim row = dataTable.NewRow()
            row.Item("Id") = i
            row.Item("Username") = "user." & i
            row.Item("Color") = String.Format("#{0:X6}", random.Next(&H1000000))
            dataTable.Rows.Add(row)
        Next

        Return dataTable
    End Function
End Class
