title: Find textbox control in ASP dynamic table
body: <p>I am dynamically creating a table that contains a textbox. I am doing so with the following code:</p>
  
  <pre><code>foreach (DataRow row in Score_Sheet.Rows) // Loop over the rows.
                  {
                      int rowIndex = Score_Sheet.Rows.IndexOf(row); // Not sure if i need this yet
  
                      Label label = new Label();
                      TextBox txt = new TextBox();
                      txt.Text = row["Value"].ToString();
                      txt.ID = row["Risk"].ToString();
                      label.Text = row["Risk"].ToString() + "      =      ";
                      rows = new TableRow();
                      cell = new TableCell();
                      cell.Controls.Add(label);
                      cell2 = new TableCell();
                      cell2.Controls.Add(txt);
  
  
                      rows.Controls.Add(cell);
                      rows.Controls.Add(cell2);
                      SSGrid.Controls.Add(rows);
  
  
                  }
  </code></pre>
  
  <p>this is adding a Table to my webpage via this code:</p>
  
  <pre><code> &lt;asp:Table ID="SSGrid" runat="server"&gt;&lt;/asp:Table&gt;
  </code></pre>
  
  <p>the table is populating correctly, however when I try to access the updated value from the textbox in the table I get a null reference exception. </p>
  
  <p>my find control code is this:</p>
  
  <pre><code>TextBox txt_any = (TextBox)SSGrid.FindControl("ANY");
                  string anyany = txt_any.Text;
                  row1["Value"] = any;
  </code></pre>
  
  <p>how can I access the values that are being updated in this textbox?</p>
  
  <p>thanks!</p>