Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:GridView ID="GridView1" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging" EnableModelValidation="true" OnRowEditing="GridView1_RowEditing" AutoGenerateColumns="False" runat="server" AllowPaging="True" ShowHeaderWhenEmpty="True" AllowSorting="True" DataKeyNames="Id" OnRowUpdating="GridView1_RowUpdating" OnRowDataBound="GridView1_RowDataBound" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black">
                       <Columns>
                           <asp:TemplateField HeaderText="ID">
                               <HeaderTemplate>
                                   <asp:TextBox ID="txtid"  runat="server" CssClass="search_textbox" placeholder="Id"></asp:TextBox>
                               <asp:LinkButton ID="lnkbtnid" runat="server" Text="Id" ForeColor="White"></asp:LinkButton>
                               </HeaderTemplate>
                               <ItemTemplate>
                                   <asp:Label ID="lblcustid" runat="server" Text='<%#Eval("Id") %>'></asp:Label>
                               </ItemTemplate>

                           </asp:TemplateField>





I want to find header template textbox control on page load
Posted
Updated 7-Sep-14 21:40pm
v2
Comments
Sinisa Hajnal 8-Sep-14 4:16am    
Server or client side? that is, do you need it in the code behind or in some javascript / jQuery function?
Tejas Vaishnav 8-Sep-14 4:38am    
What you want to do, after getting access to that text box, you need to place any text on it or any thing else.
sureshsharma123 8-Sep-14 5:41am    
place a value by querystring

1 solution

Try this:
C#
foreach(GridViewRow gdv in GridView1.Rows){
     if (gdv.RowType == DataControlRowType.Header)
     {
         //Find the control here.
         TextBox txt = (TextBox)gdv.HeaderRow.FindControl("txt");
     }
}



--Amy
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900