D
Dany P. Wu
Hi everyone,
I created a page which contains a two-column table. The first column has a
bunch of labels, and the second a bunch of textboxes. Here's the code:
======================================================
Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder
Private Sub ConstructEditTable()
Container.Controls.Add(New LiteralControl("<table>" & vbNewLine))
Dim i As Integer
For i = 0 To rows
With Container.Controls
.Add(New LiteralControl("<tr>" & vbNewLine))
'Label column
.Add(New LiteralControl("<td>" & vbNewLine))
label = New Label
label.ID = "lbl" & i.ToString
label.Text = i.ToString
label.EnableViewState = True
.Add(label)
.Add(New LiteralControl("</td>" & vbNewLine))
'Textbox column
.Add(New LiteralControl("<td>" & vbNewLine))
txtTest = New TextBox
txtTest.ID = "txt" & i.ToString
txtTest.Width = Unit.Pixel(50)
txtTest.EnableViewState = True
.Add(txtTest)
.Add(New LiteralControl("</td>" & vbNewLine))
.Add(New LiteralControl("</tr>" & vbNewLine))
End With
Next
Container.Controls.Add(New LiteralControl("</table>" & vbNewLine))
End Sub
==========================================================
The problem I have is accessing the content of the textboxes after postback.
How do I iterate through the controls in Container? Basically, after
PostBack, I would like to display the same table but with labels in the
second column, instead of textboxes. These labels would display the content
of the textboxes entered prior to PostBack.
Any ideas anyone? Any suggestions would be greatly appreciated.
Cheers,
Dany.
I created a page which contains a two-column table. The first column has a
bunch of labels, and the second a bunch of textboxes. Here's the code:
======================================================
Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder
Private Sub ConstructEditTable()
Container.Controls.Add(New LiteralControl("<table>" & vbNewLine))
Dim i As Integer
For i = 0 To rows
With Container.Controls
.Add(New LiteralControl("<tr>" & vbNewLine))
'Label column
.Add(New LiteralControl("<td>" & vbNewLine))
label = New Label
label.ID = "lbl" & i.ToString
label.Text = i.ToString
label.EnableViewState = True
.Add(label)
.Add(New LiteralControl("</td>" & vbNewLine))
'Textbox column
.Add(New LiteralControl("<td>" & vbNewLine))
txtTest = New TextBox
txtTest.ID = "txt" & i.ToString
txtTest.Width = Unit.Pixel(50)
txtTest.EnableViewState = True
.Add(txtTest)
.Add(New LiteralControl("</td>" & vbNewLine))
.Add(New LiteralControl("</tr>" & vbNewLine))
End With
Next
Container.Controls.Add(New LiteralControl("</table>" & vbNewLine))
End Sub
==========================================================
The problem I have is accessing the content of the textboxes after postback.
How do I iterate through the controls in Container? Basically, after
PostBack, I would like to display the same table but with labels in the
second column, instead of textboxes. These labels would display the content
of the textboxes entered prior to PostBack.
Any ideas anyone? Any suggestions would be greatly appreciated.
Cheers,
Dany.