473,467 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reference controls

Hello,

How do you reference a label inside a repeater? I tried the following and
got the error:

Object reference not set to an instance of an object.

((Label)this.rptRSS.FindControl("lblRSSFeed")).Tex t = "My Value";
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<table class="tblOutline" border="1px" style="width:99%">
<tr>
<th style="width:50%"><asp:Label id="lblRSSFeed" runat="server" /></td>
</tr>
Thanks, sck10
Oct 5 '06 #1
3 1461
the repeater has a itemplate control for each repeated template block,
header and footer. to access a control, walk the templates until you find
the one you want (check type and whatever you used for binding), then you
can find the child control.

-- bruce (sqlwork.com)
"sck10" <sc***@online.nospamwrote in message
news:ej**************@TK2MSFTNGP06.phx.gbl...
Hello,

How do you reference a label inside a repeater? I tried the following and
got the error:

Object reference not set to an instance of an object.

((Label)this.rptRSS.FindControl("lblRSSFeed")).Tex t = "My Value";
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<table class="tblOutline" border="1px" style="width:99%">
<tr>
<th style="width:50%"><asp:Label id="lblRSSFeed" runat="server" /></td>
</tr>
Thanks, sck10

Oct 5 '06 #2
q
Better yet... here's how to find out. Break in the ItemDataBound event
for the repeater and play with finding the control in the tree in the
immediate window. To get to the immediate window... type "immed" in
the command window.

Now when doing this at times you will want to see a parent... so you're
tree walk will look something like this.

((PlaceHolder)((MultiView)((RepeaterItem)control.F indControl("ctlMyControl")).Parent).Parent).Visibl e

That's just an example, but it's an example of how long it can get. If
you do any WPF work in the future, it's the same idea there too.

On Oct 5, 4:26 pm, "sck10" <s...@online.nospamwrote:
Hello,

How do you reference a label inside a repeater? I tried the following and
got the error:

Object reference not set to an instance of an object.

((Label)this.rptRSS.FindControl("lblRSSFeed")).Tex t = "My Value";

<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<table class="tblOutline" border="1px" style="width:99%">
<tr>
<th style="width:50%"><asp:Label id="lblRSSFeed" runat="server" /></td>
</tr>

Thanks, sck10
Oct 5 '06 #3
Thanks q...
"q" <ag******@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Better yet... here's how to find out. Break in the ItemDataBound event
for the repeater and play with finding the control in the tree in the
immediate window. To get to the immediate window... type "immed" in
the command window.

Now when doing this at times you will want to see a parent... so you're
tree walk will look something like this.

((PlaceHolder)((MultiView)((RepeaterItem)control.F indControl("ctlMyControl")).Parent).Parent).Visibl e

That's just an example, but it's an example of how long it can get. If
you do any WPF work in the future, it's the same idea there too.

On Oct 5, 4:26 pm, "sck10" <s...@online.nospamwrote:
>Hello,

How do you reference a label inside a repeater? I tried the following
and
got the error:

Object reference not set to an instance of an object.

((Label)this.rptRSS.FindControl("lblRSSFeed")).Te xt = "My Value";

<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<table class="tblOutline" border="1px" style="width:99%">
<tr>
<th style="width:50%"><asp:Label id="lblRSSFeed" runat="server"
/></td>
</tr>

Thanks, sck10

Oct 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Poewood | last post by:
Okay here are four classes for a pocket pc program: Input, fpositional, ComboBoxArray and TextBoxArray. The "input" class is the form. I use the fpositional class to handle most of the functions...
0
by: Stephen Cairns | last post by:
I have the following rpx file in a .Net solution and I am getting the following build errors which are driving me crazy and ive no idea where I have went wrong. The build errors I'm getting are as...
1
by: M Shafaat | last post by:
Hi! I have made a user control called, say "MyUserCtrl", which is inherited from another user defined class called, say "MyBaseClass". Each one of these two are developed in its own project. ...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
14
by: 97T | last post by:
Well this is still bugging me. I know there are other ways around this, but for a number of reasons I would like to be able to do this one simple thing. I have a form with a number of controls...
10
by: Richard Lewis Haggard | last post by:
I've created in form that has tab controls that contain tab controls that host user controls on each tab page. It compiles and runs just fine but the designer view fails with a "A circular control...
1
by: mark_vogt | last post by:
Greetings all, Here's an interesting problem that (oddly) has never happened to me before: ====================================================== A. I just purchased 2 different controls from...
17
by: Blau | last post by:
I'm trying to use the System.Windows.Controls namespace, but when I try to add a reference to it I don't see it in the list. I see a System.Windows.Forms, but not a System.Windows.Controls. Can...
9
by: =?Utf-8?B?VG9tbXkgTG9uZw==?= | last post by:
I don't know if the following is what you are looking for, but to me what you described was using a control array. If you were using vb6 that would be easy, the following articles hopefully...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.