This code works fine on a form:
VB Code:
  1. Dim t As New Table
  2.         Dim tr As New TableRow
  3.         Dim tc As New TableCell
  4.  
  5.         Dim b As New Button
  6.         b.Text = "Button 1"
  7.  
  8.         tc.Controls.Add(b)
  9.         tr.Cells.Add(tc)
  10.         t.Rows.Add(tr)
  11.  
  12.         tr = New TableRow
  13.         tc = New TableCell
  14.         b = New Button
  15.  
  16.         b.Text = "Button 2"
  17.         tc.Controls.Add(b)
  18.         tr.Cells.Add(tc)
  19.         t.Rows.Add(tr)
  20.  
  21.         PlaceHolder1.Controls.Add(t)

But when I try to do something similar in a Web Custom Control, it doesn't work:
VB Code:
  1. ' Page_Load
  2.         Dim b As New Button
  3.         b.Text = "Button 1"
  4.  
  5.         repeat.Controls.Add(b)
  6.  
  7.         b = New Button
  8.  
  9.         b.Text = "Button 2"
  10.         repeat.Controls.Add(b)
VB Code:
  1. ' Web Custom Control Render
  2.     Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
  3.  
  4.         Dim t As New Table
  5.  
  6.         For Each ctrl As Control In Me.Controls
  7.             Dim tr As New TableRow
  8.             Dim tc As New TableCell
  9.  
  10.             Debug.WriteLine(ctrl.ClientID)
  11.  
  12.             ' The next line causes the problem
  13.             tc.Controls.Add(ctrl)
  14.  
  15.             tr.Cells.Add(tc)
  16.             t.Rows.Add(tr)
  17.  
  18.         Next
  19.  
  20.         t.RenderControl(output)
  21.  
  22.     End Sub
When I use the control on Page_Load, only one button is shown...
Why won't this work?