Trouble creating a multiple Row Table from Server Side Code
<p>I am trying to create a table dynamically in my code behind.  My problem is I have a count of how many controls I want added to each TableRow after which I want to add that TableRow to the table and then start a new row.  Here is the code I have no far but it just adds one row and does not move any of the controls to a seperate new row.  </p>

<pre><code>public void FillTable(string DB, int? appID, string function, int? rID, string UserId, int ControlsperRow)
{
    OneEvaDataContext datacontext = new OneEvaDataContext();

    var results = datacontext.sp_Build_Menu_Field_Names(DB, appID, function, rID);
    int controlCount = 0;

    TableRow tr = new TableRow();
    foreach (sp_Build_Menu_Field_NamesResult result in results)
    {

            TableCell tcLabel = new TableCell();
            TableCell TcControl = new TableCell();
            Control control = new Control();

            control = DynamicControlReturn.ReturnControl(result.Param_Name, result.Build_Options_Type_NAME, UserId);
            control.ID = "control" + controlCount.ToString();

            _controlClientIDList.Add(control.ClientID);

            tcLabel.Text = result.Param_Label;
            TcControl.Controls.Add(control);
            tr.Cells.Add(tcLabel);
            tr.Cells.Add(TcControl);

            controlCount = controlCount + Convert.ToInt32(result.TD_Len);

            if (controlCount == ControlsperRow)
            {
                base.Controls.Add(tr);
                controlCount = 0;
            }
    }
} 
</code></pre>

<p>I would have thought that doing the .Add only when I am finished building that row would work but I guess since I'm using the same TableRow "tr" It is only putting in just one row.</p>

<p>EDIT:  in the is context base is my class which looks like this:</p>

<pre><code>  public class Dynamic_Search_Table : System.Web.UI.WebControls.Table
    {
</code></pre>
