Asp.Net textbox is not declared error when textbox is in gridview header -


i adding several textboxes asp.net gridview below header of each column, in order use them filter input fields.

the thing when try run following error on each field:

error   3   'txts_ap' not declared. may inaccessible due protection level.   

if take out textboxes outside of gridview, no errors, assume there "special" putting fields within gridview.

i appreciate if can on how avoid this. thanks

<asp:templatefield >   <headertemplate>     <asp:linkbutton id="lbap" runat="server" text="ap" style="color:white;" commandname="sort" commandargument="ap"></asp:linkbutton> <br />     <asp:textbox runat="server" id="txts_ap"  cssclass="std_searchfields" autopostback="true" ></asp:textbox>   </headertemplate>             <itemtemplate>                                                   <table  >            <tr >            <td class="std_normal" style="width:100px;"><%#eval("ap")%></td>                                                                </tr>             <tr>            <td class="std_normal_grey" style="width:100px; height:20px"><%#eval("ounckn")%> (<%#eval("orc")%>)</td>            </tr>            </table>                                                    </itemtemplate>                                              <headerstyle horizontalalign="left" /> </asp:templatefield> 

since it's inside of container have declare , find before using. can this:

vb.net:

dim txts_ap textbox = gridview1.headerrow.findcontrol("txts_ap") 

c#

textbox txts_ap = (textbox)gridview1.headerrow.findcontrol("txts_ap"); 

once - should able access it's properties (here assuming gridview1 grid id.)


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -