1. The scope that the FindControl method is looking for is the descendant control for the given controls.
Copy Code code as follows:
<form id= "Form1" runat= "Server" >
<asp:label id= "Label1" runat= "Server" text= "Label" ></asp:Label>
<asp:panel id= "Panel1" runat= "Server" >
<asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<asp:button id= "Button1" runat= "Server" text= "button"/>
</asp:Panel>
</form>
such as the above code, the background with Panel1.findcontrol ("Button1") to find, that such a small range can improve efficiency, in fact, even with Textbox1.findcontrol ("Button1") can also be found. Previously, the FindControl method looks for the corresponding control in the naming container in which it resides based on the ID. When the Textbox1.findcontrol ("Button1") is executed, the ASP. NET to get Textbox1.namingcontainer, the value of the page itself (the last generated Xxxx_aspx class instance), and then recursively look for the corresponding ID of the control, so the same can find Button1.
Similarly, if you use Textbox1.findcontrol ("Label1") you can also find Label1.
2. Don't understand why this. The FindControl method could not find the control in the GridView.
In fact, it is well understood that the FindControl method is searched only under this naming container, and does not go into other naming containers, while the naming container (NamingContainer) is not just the page itself, but also includes GridViewRow, DataListItem, Many controls, such as RepeaterItem, UserControl, masterpage, and so on, inherit the INamingContainer interface, One notable feature of these is that the UniqueID and ClientID of their child controls are generally different from IDs (except for the top-level page objects).
3. It is considered that FindControl operation efficiency is poor.
In fact, asp.net runtime analysis of aspx, ascx, master, and other file tag structure, to produce a tree like the DOM, the general query operation efficiency is relatively high, especially when the problem is not too large. In general, the number of controls in the actual page cannot be thousands, and the search cannot cross this naming container, limiting the size of the problem. So the efficiency of FindControl is not bad.