473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Repeater, FindControl

1
Hi,

I have a html table inside a repeater control. There is a row in the table that I need to toggle the visibility of. I have set the <tr> to runat="server" and have given it the ID of "trSwitch".

In the code behind, I have the following:

HtmlTableRow trSwitch = (HtmlTableRow)Repeater1.FindControl("trSwitch");
trSwitch.Visible = true;

But when I run the page I get a 'Object reference not set to an instance of an object"...

How can I successfully find the <tr> in the repeater?

Thanks in advance.
Sep 16 '08 #1
1 2279
Frinavale
9,735 Expert Mod 8TB
Hi,

I have a html table inside a repeater control. There is a row in the table that I need to toggle the visibility of. I have set the <tr> to runat="server" and have given it the ID of "trSwitch".

In the code behind, I have the following:

HtmlTableRow trSwitch = (HtmlTableRow)Repeater1.FindControl("trSwitch");
trSwitch.Visible = true;

But when I run the page I get a 'Object reference not set to an instance of an object"...

How can I successfully find the <tr> in the repeater?

Thanks in advance.
When you set the Visibility of something using the .NET server code that object is not rendered in the html page.

Instead of using server side code to hide the row, set the row's CSS "visibility" or "display" property to hide the row...

eg
Expand|Select|Wrap|Line Numbers
  1. <tr style="display:none"></tr>
  2.  
Also, I don't think that a <tr> can be accessed through the FindControl method. The FindControl method is used to find a control, not a table row.

Therefore, when you are creating the <tr> be sure to set the CSS there.


-Frinny
Sep 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
1
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has...
3
by: Kelly Leahy | last post by:
I'm using an Asp:Repeater control with a text box in the item templates. This is for a system that has a number of items that the user can edit and I'd like to generate them based on a list. ...
2
by: Benjamin Bittner | last post by:
Hi NG, my problem is pretty simple i think. ive got a repeater with a textbox and a button. after submitting the page with the button, i want to get the textbox.text value. but i dont seem to find...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
4
by: Dennis E. Jones, Jr. | last post by:
I'm creating a dynamic control for each row in a REPEATER based on database values. ItemDataBound creates the control for the initial load (not postback), but I cannot get the control recreated...
8
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
15
by: | last post by:
I dynamically create controls (textboxes) in a repeater control. I know their names (eg. TextBox1). How do I find the text of TextBox1 in the Form? FindControl does not seem to work.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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...

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.