title: Gridview Get Value Textbox
body: <p>Dynamically create textbox in gridview this way: </p>
  
  <pre><code>int index = e.Row.RowIndex;
  int tot = e.Row.Cells.Count;
  for (int i = 1; i &lt; tot; i++)
  {
      TextBox txtValor = new TextBox();
  
      txtValor.Width = 15;
      txtValor.BorderStyle = BorderStyle.Ridge;
      txtValor.ID = "txt"+index.ToString()+i.ToString();
      txtValor.Attributes.Add("runat", "server"); 
      txtValor.Text = (e.Row.DataItem as DataRowView).Row[produ].ToString();
      e.Row.Cells[i].Controls.Add(txtValor);              
  }
  </code></pre>
  
  <p>I can not get the value, already tried these ways:</p>
  
  <pre><code>quant = GridView1.Rows[i].Cells[j].Text;
  quant = ((TextBox)(GridView1.Rows[i].Cells[j].Controls[0])).Text;
  quant = ((TextBox)GridView1.Rows[i].Cells[j].FindControl("txt"+i.ToString()+j.ToString())).Text;
  quant = GridView1.Rows[i].Cells[j].Text; // this way i get the value of the cell and not the textbox
  </code></pre>
  
  <p>Tgis is the code-behind ASPX: the textbox was create by row databound.</p>
  
  <pre><code>   &lt;asp:GridView ID="GridView1" runat="server" CellPadding="4" Font-Size="XX-Small" ForeColor="#333333" Width="100%" HorizontalAlign="Center" PageSize="35" OnRowDataBound="GridView1_RowDataBound"&gt;
          &lt;AlternatingRowStyle BackColor="White" ForeColor="#6E7265" /&gt;
          &lt;EditRowStyle BackColor="#999999" /&gt;
          &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
          &lt;HeaderStyle BackColor="#BDC0C4" Font-Bold="True" ForeColor="#333333" /&gt;
          &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
          &lt;RowStyle BackColor="White" ForeColor="#333333" Wrap="True" BorderStyle="Double" BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
          &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
          &lt;SortedAscendingCellStyle BackColor="#E9E7E2" /&gt;
          &lt;SortedAscendingHeaderStyle BackColor="#506C8C" ForeColor="White" /&gt;
          &lt;SortedDescendingCellStyle BackColor="#FFFDF8" /&gt;
          &lt;SortedDescendingHeaderStyle BackColor="#6F8DAE" /
      &lt;/asp:GridView&gt;
  </code></pre>