I am trying to programmaticall y add rows of data to a table web control
in VS2005. I am getting the data from 2 drop-down controls and 2
text-boxes. The code below is executed when I click on the "add"
button. The code is pretty much lifted from an example on MSDN.
Problem:
The first time I try to add a row, it works fine. But when I try to add
another row, it simply overwrites the first. I need to add new row
every time the user clicks the 'add' button.
--------------------------------
Protected Sub btnProdAdd_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnProdAdd.Clic k
Dim tr As New TableRow()
Dim cellGrade As New TableCell()
cellGrade.Text = cboGrade.Select edValue.ToStrin g
tr.Cells.Add(ce llGrade)
Dim cellStrips As New TableCell()
cellStrips.Text = cboStrips.Selec tedValue.ToStri ng
tr.Cells.Add(ce llStrips)
Dim cellYards As New TableCell()
cellYards.Text = txtYards.Text.T oString
tr.Cells.Add(ce llYards)
Dim cellScrap As New TableCell()
cellScrap.Text = txtScrap.Text.T oString
tr.Cells.Add(ce llScrap)
tblProd.Rows.Ad d(tr)
End Sub
in VS2005. I am getting the data from 2 drop-down controls and 2
text-boxes. The code below is executed when I click on the "add"
button. The code is pretty much lifted from an example on MSDN.
Problem:
The first time I try to add a row, it works fine. But when I try to add
another row, it simply overwrites the first. I need to add new row
every time the user clicks the 'add' button.
--------------------------------
Protected Sub btnProdAdd_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnProdAdd.Clic k
Dim tr As New TableRow()
Dim cellGrade As New TableCell()
cellGrade.Text = cboGrade.Select edValue.ToStrin g
tr.Cells.Add(ce llGrade)
Dim cellStrips As New TableCell()
cellStrips.Text = cboStrips.Selec tedValue.ToStri ng
tr.Cells.Add(ce llStrips)
Dim cellYards As New TableCell()
cellYards.Text = txtYards.Text.T oString
tr.Cells.Add(ce llYards)
Dim cellScrap As New TableCell()
cellScrap.Text = txtScrap.Text.T oString
tr.Cells.Add(ce llScrap)
tblProd.Rows.Ad d(tr)
End Sub
Comment