A method on the Control class in the .NET framework that finds a control from its id. The control is only found if it is within the calling control's naming container.
Questions tagged [findcontrol]
374 questions
122
votes
8 answers
How to find controls in a repeater header or footer
I was wondering how one would find the controls in the HeaderTemplate or FooterTemplate of an Asp.Net Repeater control.
I can access them on the ItemDataBound event, but I was wondering how to get them after (for example to retrieve a value of an…

mbillard
- 38,386
- 18
- 74
- 98
49
votes
9 answers
Better way to find control in ASP.NET
I have a complex asp.net form,having even 50 to 60 fields in one form like there is Multiview, inside MultiView I have a GridView, and inside GridView I have several CheckBoxes.
Currently I am using chaining of the FindControl() method and…

santosh singh
- 27,666
- 26
- 83
- 129
30
votes
7 answers
ASP.Net FindControl is not working - How come?
I have used FindControl in the past, prior to .NET 2.0/3.0. It seems like now, for some reason, the ID's of my controls get a funky named assigned. For example I assigned an id "cbSelect" to a checkbox, but FindControl does not find it. When I…

LilMoke
- 3,176
- 7
- 48
- 88
29
votes
7 answers
How to find Control in TemplateField of GridView?
How does FindControl method works if I need to find any Control which is inside GridView Template, more specifically ItemTemplate?
I have a hyperlink but it is not able to find the same.
Question updated with code
GridView Code is…

xorpower
- 17,975
- 51
- 129
- 180
28
votes
5 answers
Finding control within WPF itemscontrol
Hi i have few a single textbox within the the datatemplate for itemscontrol. When i bind the itemcontrols to a observable collection i get two text boxes. But i need to do some manipulations based on each of the text boxes for which i want to find…

deepak
- 983
- 3
- 15
- 19
19
votes
3 answers
Find a control on a page with a master page
I have to find a Control in an aspx page bound to a master page.
The master page contains:
The content page contains:

Aladdin Gallas
- 701
- 2
- 12
- 36
15
votes
4 answers
Find all child controls of specific type using Enumerable.OfType() or LINQ
Existed MyControl1.Controls.OfType() searches only thru initial collection and do not enters to children.
Is it possible to find all child controls of specific type using Enumerable.OfType() or LINQ without writing own recursive…

abatishchev
- 98,240
- 88
- 296
- 433
13
votes
5 answers
Using FindControl() to find control
I have a Literal control that I am trying to locate so I can insert text into it. I have a Master page that contains several content placeholders.
Project…

Mike Wills
- 20,959
- 28
- 93
- 149
12
votes
6 answers
Find control in ListView EmptyDataTemplate
I have the a ListView like this
...
In Page_Load() I have the…

Caline
- 175
- 1
- 1
- 7
11
votes
5 answers
How do I access a control in the HeaderTemplate of my GridView
I want to have a DropDownList in the header of my GridView. In My codebehind I can't seem to access it. Here is the HeaderTemplate:

minty
- 22,235
- 40
- 89
- 106
9
votes
4 answers
FindControl Returning Null
I am trying to contol a buttons state depending on a relevant text box. The names are the same other than the prefixes. The text boxes and buttons are located in a table on the page.
…

nickson104
- 580
- 1
- 7
- 18
9
votes
7 answers
Nested Masterpages and .FindControl
On one site, I'm only using a single level Masterpage and in a page using that master, I can do this.Master.FindControl("controlName") to access the control. Works fine.
However, using the same code on a site with two masterpage levels. MainMaster…

klkitchens
- 1,202
- 2
- 16
- 39
9
votes
3 answers
C#, FindControl
I'm sorry, but I can't understand why this doesn't work. After compile, I receive a "Null reference exception". Please help.
public partial class labs_test : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
…

AlexC
- 9,657
- 17
- 64
- 98
8
votes
4 answers
c# - error using FindControl on div id
I have an ASP.NET site that I am trying to access div elements by their ID from the C# code behind file. Essentially I want to see if a div element exists, and if so, alter its properties.
I've found many resources out there that point to a dozen…

JasonH
- 1,221
- 2
- 19
- 19
6
votes
5 answers
Access a content control in C# when using Master Pages
Good day everyone,
I am building a page in ASP.NET, and using Master Pages in the process.
I have a Content Place Holder name "cphBody" in my Master Page, which will contain the body of each Page for which that Master Page is the Master Page.
In the…

Guillaume Gervais
- 1,035
- 2
- 14
- 26