Private Sub LoadFormUI()
'Dim all the stuff we need for the table of controls
Dim x As Integer
Dim Formtable As New Table
Dim HeadingRow As New TableRow
Dim HeadingCell1 As New TableHeaderCell
Dim HeadingCell2 As New TableHeaderCell
Dim HeadingCell3 As New TableHeaderCell
Dim HeadingCell4 As New TableHeaderCell
Dim HeadingCell5 As New TableHeaderCell
Dim HeadingCell6 As New TableHeaderCell
Dim HeadingCell7 As New TableHeaderCell
'Set the table border and name
Formtable.BorderWidth = WebControls.Unit.Pixel(1)
Formtable.ID = "Batchtable"
'add the table to the placeholder
phTable.Controls.Add(Formtable)
'set the text in the cell heading controls
HeadingCell1.Text = "Invoice #"
HeadingCell2.Text = "Incentive"
HeadingCell3.Text = "Quantity"
HeadingCell4.Text = "Total Pay"
'Add the headingrow control to the table that was addedd to the placeholder control
Formtable.Controls.Add(HeadingRow)
'Now add the column heading controls to the headingrow control
HeadingRow.Controls.Add(HeadingCell1)
HeadingRow.Controls.Add(HeadingCell2)
HeadingRow.Controls.Add(HeadingCell3)
HeadingRow.Controls.Add(HeadingCell4)
'this for-next loop will create 40 rows with the controls for each row
For x = 0 To 40
'Create a new tablerow control
Dim FormRow As New TableRow
'create the cell controls for the tablerow control
Dim Cell1 As New TableCell
Dim Cell2 As New TableCell
Dim cell3 As New TableCell
Dim cell4 As New TableCell
'create textbox controls for the tablecells
Dim txtCol1 As New TextBox 'Invoice#
Dim txtCol2 As New eWorld.UI.NumericBox 'Incentive
Dim txtCol3 As New eWorld.UI.NumericBox 'Quantity
Dim txtCol4 As New eWorld.UI.NumericBox 'Total Pay
'eWorld.UI.Numericbox is a custom serverside control that only allows numeric values and currency values, it does not allow for any alpha text. This control is propietary, and belongs to [URL unfurl="true"]http://www.eworldui.net/[/URL] the control was provided freely at the time we downloaded the control, as it turns out the control may not be free in the future, we hope so.
'Set the Row border and color
FormRow.BorderWidth = WebControls.Unit.Pixel(3)
FormRow.BorderColor = Color.Black
'add the new Tablerow to the table
Formtable.Controls.Add(FormRow)
'add the textbox controls to the newly added tablerow
FormRow.Controls.Add(Cell1)
FormRow.Controls.Add(Cell2)
FormRow.Controls.Add(cell3)
FormRow.Controls.Add(cell4)
'set the textbox control ID's so we can reference them later in code we use the format controlname_rownumber. ie txtCol1_1 = textbox in column 1 row 1
txtCol1.ID = "txtCol1_" & x.ToString : txtCol1.Columns = 8
txtCol2.ID = "txtCol2_" & x.ToString : txtCol2.Columns = 7 : txtCol2.DecimalPlaces = 2 : txtCol2.AutoFormatCurrency = True
txtCol3.ID = "txtCol3_" & x.ToString : txtCol3.Columns = 10
txtCol4.ID = "txtCol4_" & x.ToString : txtCol4.Columns = 7 : txtCol4.DecimalPlaces = 2 : txtCol4.AutoFormatCurrency = True
'now add the textbox controls to each of the cells in the new tablerow
Cell1.Controls.Add(txtCol1)
Cell2.Controls.Add(txtCol2)
cell3.Controls.Add(txtCol3)
cell4.Controls.Add(txtCol4)
' This adds a handler to the form so we can trap the textchanged event of the textbox in column 2
'AddHandler txtCol2.TextChanged, AddressOf txtCol2_TextChanged
Next
End Sub