htHow to find control of Textbox in table cell which is inside Gridview
<p>I have a gridview and I have few records and I have one table cell at the top inside the gridview with a textbox and a button  to filter the records. How do I find the control of that textbox.</p>

<pre><code>protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            GridViewRow HeaderGridRow = new GridViewRow(0, 1, DataControlRowType.Header, DataControlRowState.Normal);
            TableCell HeaderCell = new TableCell();

            HeaderCell.Text = "";
            TextBox abc = new TextBox();
            HeaderCell.Controls.Add(abc);
            HeaderCell.ColumnSpan = 3;
            HeaderGridRow.Cells.Add(HeaderCell);

            HeaderCell = new TableCell();
            HeaderCell.Text = "";
            TextBox search = new TextBox();
            search.ID = "search1";
            HeaderCell.Controls.Add(search);
            HeaderCell.ColumnSpan = 3;
            HeaderGridRow.Cells.Add(HeaderCell);
            Control ctrl = HeaderGridRow.Cells[1].Controls[0];
            TextBox tc = ctrl as TextBox;


            HeaderCell = new TableCell();

            Button btn_chk = new Button();
            btn_chk.Text = "go";
            HeaderCell.Controls.Add(btn_chk);
            HeaderCell.ColumnSpan = 1;
            btn_chk.Click += new EventHandler(btnClick);
            HeaderGridRow.Cells.Add(HeaderCell);

            //btn_chk.CommandName = "btn_chk";

            GridView2.Controls[0].Controls.AddAt(0, HeaderGridRow);


        }
    }

        html part

         &lt;asp:GridView ID="GridView2" runat="server"            OnRowCreated="GridView2_RowCreated"&gt;   
                    &lt;Columns&gt;
                        &lt;asp:TemplateField&gt;

     &lt;%--   &lt;HeaderTemplate&gt;
     Planning Id&lt;br /&gt;
        &lt;asp:TextBox ID="txt_planningid" runat="server"&gt;&lt;/asp:TextBox&gt;
    &lt;/HeaderTemplate&gt;--%&gt;                     
                            &lt;HeaderTemplate&gt;
                                &lt;asp:Label ID="Label9" runat="server" Text="S.No"&gt;&lt;/asp:Label&gt;
                            &lt;/HeaderTemplate&gt;

                            &lt;ItemTemplate&gt;
                                &lt;asp:Label ID="Label8" runat="server" Text="&lt;%#Container.DataItemIndex+1 %&gt; "&gt;&lt;/asp:Label&gt;
                            &lt;/ItemTemplate&gt;

                        &lt;/asp:TemplateField&gt;

                    &lt;/Columns&gt;

                &lt;/asp:GridView&gt;
</code></pre>

<p>I have added two textboxes and one button using table cell in rowcreated event..</p>