I have been working on a webform where I need to generatet a dynamic html table. Then with each button click I need to add a row with cells to the table. My problem is when I click my add row button it mearly wirtes over the existing row.
Here is the code I have so far.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim tblName As New HtmlTable
'following lines set date fields to now by default
Dim myDate As Date = Now
txtDate.Text = Format(myDate, "MM/dd/yyyy")
txtLdod.Text = Format(myDate, "MM/dd/yyyy")
txtEmpSigDate.Text = Format(myDate, "MM/dd/yyyy")
txtHrmDate.Text = Format(myDate, "MM/dd/yyyy")
'Dim dynamicMaskedTextBox As New MaskedTextBox()
'Dim dtDate As Date
'txtDate.Text = Format(Date, "mm-dd-yyyy")
' txtLdod.Text = Format("mm-dd-yyy")
' txtEmpSigDate.Text = Format("mm-dd-yyy")
' txtHrmDate.Text = Format("mm-dd-yyy")
' Format(txtDate.Text, vbShortDate)
End Sub
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click
Dim tblTr As New HtmlTableRow()
Dim strNumberOfUnits, strItem, strSerial As New HtmlTableCell()
Dim tb As New TextBox
Dim tblRows As Integer
Dim tblCloumns As Integer
'add new row
tblName.Rows.Add(tblTr)
'Sets the number of items
tblTr.Cells.Add(strNumberOfUnits)
strNumberOfUnits.InnerText = "1"
strNumberOfUnits.ID = "strNumberOfUnits" & tblName.Rows.Count - 1
'set item descriptor
tblTr.Cells.Add(strItem)
strItem.InnerText = ddlProperty.SelectedValue.ToString
strItem.ID = "strItem" & tblName.Rows.Count - 1
'set serial value
tblTr.Cells.Add(strSerial)
strSerial.Controls.Add(tb)
tb.ID = "txt" & ddlProperty.SelectedValue.ToString & tblName.Rows.Count - 1
'sets serial field
'Dim tx As New TextBox
'tblTr.Controls.Add(tx)
'tx.ID = "Row_" & tblName.Rows.Count - 1
''strSerial.InnerText = InputBox("Input corresponding item/Serial number", "Items Number")
''tblTr.Cells.Add(strSerial)
End Sub
Thank you for your help.