Questions tagged [findcontrol]

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.

371 questions
120
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
  • 36,360
  • 18
  • 71
  • 97
48
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
  • 25,036
  • 23
  • 75
  • 121
29
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
  • 2,812
  • 6
  • 44
  • 80
28
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
  • 15,315
  • 48
  • 116
  • 173
26
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
  • 823
  • 3
  • 15
  • 19
16
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
  • 671
  • 2
  • 11
  • 34
15
votes
3 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
  • 92,232
  • 78
  • 284
  • 421
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
  • 19,825
  • 26
  • 87
  • 143
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
10
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
  • 21,168
  • 38
  • 87
  • 105
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,160
  • 2
  • 15
  • 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,529
  • 17
  • 61
  • 96
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,151
  • 2
  • 17
  • 19
7
votes
3 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
  • 520
  • 1
  • 5
  • 18
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,015
  • 2
  • 14
  • 26
1
2 3
24 25