All pastes #447171 Raw Edit

Aeternus

public text v1 · immutable
·published 2007-04-18 21:36 UTC
rendered paste body
Partial Class _Default
    Inherits System.Web.UI.Page
    ' Constants
    Private Const NUM_ROWS = 10
    ' Fields
    Private stRowsAr(5) As sttPayRow

    Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loadTable()
    End Sub

    Private Sub loadTable()
        Dim i As Integer
        tblTest.Rows.Add(createHeaderRow())
        For i = 1 To NUM_ROWS
            tblTest.Rows.Add(createEmptyRow())
        Next
    End Sub

    Private Function createHeaderRow()
        Dim rowTemp As TableRow = New TableHeaderRow
        Dim cllHeader As TableHeaderCell = New TableHeaderCell()
        cllHeader.Text = "Paycode"
        rowTemp.Cells.Add(cllHeader)
        cllHeader = New TableHeaderCell()
        cllHeader.Text = "Description"
        rowTemp.Cells.Add(cllHeader)
        cllHeader = New TableHeaderCell()
        cllHeader.Text = "Rate"
        rowTemp.Cells.Add(cllHeader)
        cllHeader = New TableHeaderCell()
        cllHeader.Text = "Time"
        rowTemp.Cells.Add(cllHeader)
        Return rowTemp
    End Function

    Private Function createEmptyRow()
        Dim rowTemp As TableRow = New TableRow()
        Dim sttPay As sttPayRow = initPayStruct()
        rowTemp.Cells.Add(createCell(sttPay.clPaycode))
        rowTemp.Cells.Add(createCell(sttPay.clDescription))
        rowTemp.Cells.Add(createCell(sttPay.clRate))
        rowTemp.Cells.Add(createCell(sttPay.clTime))
        Return rowTemp
    End Function

    Private Function createCell(ByRef ctlCell As Control)
        Dim cllTemp As TableCell = New TableCell()
        cllTemp.Controls.Add(ctlCell)
        Return cllTemp
    End Function

    Private Function initPayStruct()
        Dim sttPay As sttPayRow = New sttPayRow()
        sttPay.clPaycode = New TextBox
        sttPay.clDescription = New TextBox()
        sttPay.clRate = New TextBox()
        sttPay.clTime = New Calendar()
        Return sttPay
    End Function


    ' Simple Row Structure
    Private Structure sttPayRow
        Public clPaycode As TextBox
        Public clDescription As TextBox
        Public clRate As TextBox
        Public clTime As Calendar
    End Structure

End Class