title: Textbox values retrieving null in code behind asp.net c#?
body: <p>I have a <code>GriView</code> which contains <code>ItemTemplates</code> but I'm not able to retrieve values in code behind. I'm getting <code>null</code> value in <code>TextBox</code>.
  here is my aspx code:</p>
  
  <pre class="lang-aspx prettyprint-override"><code>&lt;asp:GridView runat="server" ID="gridview" AutoGenerateColumns="False" Width="1100px" CellPadding="4" ForeColor="#333333" GridLines="None" Height="600px" &gt;
      &lt;AlternatingRowStyle BackColor="White" /&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Refine Requirement " HeaderStyle-Width="200px"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="TextBox1" runat="server" ForeColor="Black" Height="27px" Width="200px" Font-Size="Medium"&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
              &lt;HeaderStyle Width="200px" /&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Reason"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="REASON" TextMode="MultiLine" ForeColor="Black" Font-Size="Medium" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
   &lt;/asp:GridView&gt;
   &lt;asp:Button ID="ButtonInsert"  runat="server" ForeColor="White" BorderColor="White" OnClick="get" BorderStyle="Double" BackColor="#990000"  Text="Submit All Requirements" style="position:relative; left:400px;" /&gt;
  </code></pre>
  
  <p>and here is my code behind :</p>
  
  <pre><code>public void get(object o,EventArgs e)
  {
  foreach (GridViewRow gvr in gridview.Rows)
  {
      TextBox txtAmount = gvr.FindControl("TextBox1") as TextBox;
      string s = txtAmount.Text;
  }
  }
  </code></pre>
  
  <p>but I'm getting <code>null</code> value in <code>s</code>.</p>