Creating table rows in codebehind
<p>can someone please help me understand what needs to be done here since i'm new to C#.</p>

<p>I have one form with two buttons and a couple text boxes.</p>

<p>First, the user enters a number in one of the text boxes and then presses one of the buttons.  there is also an empty  in this form like this:</p>

<pre><code>&lt;asp:Table id="tblInputs" runat="server" Border="1" Width="100%"&gt;
&lt;/asp:Table&gt;
</code></pre>

<p>So, when the user hits the first button the code behind will add as many rows to this table is the input in the text box, like this:</p>

<pre><code>for (int i = 0; i &lt; numOfInputFields; i++) 
{
    TableRow row = new TableRow ();
    TableCell cell_inputA = new TableCell ();
    TableCell cell_inputB = new TableCell ();

    TextBox txtBox_input = new TextBox ();

    txtBox_input.ID = "txtInFld" + (i + 1);
    txtBox_input.Text = txtBox_input.ID;
    cell_inputA.Text = "Input " + (i + 1);
    cell_inputB.Controls.Add (txtBox_input);

    row.Cells.Add (cell_inputA);
    row.Cells.Add (cell_inputB);

    tblInputs.Rows.Add (row);
}
</code></pre>

<p>Now so far this works fine and the columns and rows are created fine.</p>

<p>My question now is, since the IDs for the text box were created in codebehind above, how do i access them from other codebehind functions.</p>

<p>At top of the post i mentioned i have another button in the same form that just changes the value of text in one of the newly created text boxes, but it doesn't work.</p>

<p>The regular way of saying txtInFld1.Text = "something"; doesn't work any more because it doesn't see txtInFld1 even though it was already created above. I get "The name 'txtInFld1' does not exist in current context".  I suspect it has something to do with resubmitting the same form but I'm not sure.</p>

<p>Can any one please explain what is happening here and how do i access the properties of the new text boxes created in codebehind?</p>

<p>Thanks</p>
