title: How to find a control inside a TemplateField in Gridview
body: <p>I have a gridView with a textBox inside a templateField. I wan to extract the text of the textBox if a checkbox is marked in the row.</p>
  
  <p>I have the gridView defined as follows</p>
  
  <pre><code>    &lt;asp:GridView ID="GV_Comments" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
          DataSourceID="SQL_Comments"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:CheckBox runat="server" ID="Comment_Select" /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" /&gt;
              &lt;asp:TemplateField HeaderText="comment" SortExpression="comment"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("comment") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="CommentForPeriod" runat="server" Text='&lt;%# Bind("comment") %&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt; 
      &lt;asp:Button ID="B_Load" runat="server" Text="Transfer Selection" onclick="B_Load_Click" /&gt;
      &lt;br /&gt;
      &lt;asp:TextBox ID="CompiledText" runat="server" Width="662px" Rows="10" 
          TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>And the code as follows</p>
  
  <pre><code>Protected Sub B_Load_Click(ByVal sender As Object, ByVal e As EventArgs) '(sender As Object, e As System.EventArgs) Handles B_Load.Click
      Dim FullText As String = ""
      For Each row As GridViewRow In GV_Comments.Rows
          Dim CB_Control As CheckBox = CType(row.FindControl("Comment_Select"), CheckBox)
          Dim Txt_Control As TextBox = CType(row.FindControl("CommentForPeriod"), TextBox)
          If CB_Control IsNot Nothing AndAlso CB_Control.Checked AndAlso Txt_Control IsNot Nothing Then
              FullText = FullText &amp; Txt_Control.Text &amp; "&lt;br/&gt;"
          End If
      Next row
      CompiledText.Text = FullText.ToString
  End Sub
  </code></pre>
  
  <p>When I debug the code I can see that the Checkbox control is found but not the TextBox control. Would anyone see why?</p>