title: Read a dynamically created textbox in a Gridview
body: <p>I am dynamically adding a textbox to certain rows (one column only) of a gridview.  I add the controls with this insdie of a test condition (works fine):</p>
  
  <pre><code>        TextBox txtASIN = new TextBox();
          txtASIN.ID = "TxtASIN" + e.Row.RowIndex;
          e.Row.Cells[4].Controls.Add(txtASIN);
          int i = e.Row.Cells[4].Controls.Count; //TEST: This returns 1 correctly
  </code></pre>
  
  <p>I want the user to be able to enter values into one or more of these textboxes and then update the database with a single button click (not one click for each row).  The problem I'm having is how to access those values on a button click event.  I did a simple test this way to try to see the value in the second row but get null in temp1 (I am certain there is a value entered in that textbox):</p>
  
  <pre><code>    protected void btnUpdate1_Click(object sender, EventArgs e)
      {
          TextBox temp = (TextBox)GridView2.Rows[1].FindControl("txt1");
          string temp1 = temp.Text;
          int i = GridView2.Row.Cells[4].Controls.Count; //TEST: This returns 0 incorrectly        }
  </code></pre>
  
  <p>Once I can make this work, I can iterate through the rows and do what I need to do with the values.  I don't know if the text entered in the textbox is actually readable without a postback but I'm otherwise stumped.  Open to better suggestions on how to do this.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:  Here is where I am now.  I can see the textboxes in my column fine.  I put a break in on a button that attempts to read them and this is what I'm seeing.  If I check GridView2.Rows[0].Controls.Count, I get 8, which is the correect number of columns.  If I check GridVeiw2.Rows[0].Cells[4].Controls.Count, I get 0, which is wrong because the textbox is there.  I can get a Count of 1 right after I dynamically create it but not when I perform a subsequent button click.</p>
  
  <p>Can anyone explain this?  I feel if I can get past this holdup, I can get the rest done.</p>
  
  <p>Thanks again.</p>