Asp.net grid view template fields data persist
<p>I have a grid view which contains 4 template fields, each containing a text box.</p>

<p>Now I have bound these template fields with a datasource. When I as a user type in some data in the text box and click on save button (a button which is not a part of gridview but an individual one in the webform), I am not able to get the values in the click event handler in the code behind file. Please help me.</p>

<p>ASPX file</p>

<pre class="lang-html prettyprint-override"><code>&lt;asp:TemplateField HeaderText="col1"&gt; 
    &lt;ControlStyle Height="25px" Width="60px" /&gt;
      &lt;ItemTemplate&gt;
            &lt;asp:TextBox ID="txt1" runat="server" Text='&lt;%# Bind("[col1]") %&gt;'&gt;   
            &lt;/asp:TextBox&gt;                 
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="col2"&gt;  
  &lt;ControlStyle Height="25px" Width="60px" /&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:TextBox ID="txt2" runat="server"  Text='&lt;%# Bind("[col2]") %&gt;'&gt;  
      &lt;/asp:TextBox&gt;
    &lt;/ItemTemplate&gt;
 &lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="col3"&gt; 
  &lt;ControlStyle Height="25px" Width="60px" /&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:TextBox ID="txt3" runat="server"  Text='&lt;%# Bind("[col3]") %&gt;'&gt;
      &lt;/asp:TextBox&gt;
    &lt;/ItemTemplate&gt;
 &lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="col4"&gt; 
  &lt;ControlStyle Height="25px" Width="60px" /&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:TextBox ID="txt4" runat="server"  Text='&lt;%# Bind("[col4]") %&gt;'&gt;
      &lt;/asp:TextBox&gt;
    &lt;/ItemTemplate&gt;       
&lt;/asp:TemplateField&gt;
</code></pre>

<p>Code behind file</p>

<pre><code>protected void ButtonAdd_Click(object sender, EventArgs e)
{
    foreach (GridViewRow row in gvEdit.Rows)
    {
            string a = ((TextBox)row.FindControl("col1")).Text;
                 //above line gives a null value
    }
}
</code></pre>