Solved

How to Find a Control in the footer of a repeater

Posted on 2006-11-17
3
503 Views
Last Modified: 2012-08-14
I need to access a button control that is located in the footer of a repeater.  Currently I've tried this, which returned an "Object not set to..." error.

Sub someSub()
  CType(myRepeater.FindControl("myButton"), Button).Text = "New Text"
End Sub

Is this actually possible to do from outside the RepeaterItemEventArgs sub?
0
Comment
Question by:Rouchie
3 Comments
 
LVL 3

Accepted Solution

by:
viveksg earned 300 total points
ID: 17963713

You cannot get the footer item as such outside the reapeteritemeventargs since the header, footer, and separator are not included in the item collection.

So you have to declare a repeateritem variable, assign the footer item to this variable (in itemdatabound) and then use it.

e.g: in C#.

RepeaterItem rpItem;

private void rpItem_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
   if (e.Item.ItemType == ListItemType.Footer)
          rpItem = e.Item;
}

Sub someSub()
  CType(rpItem.FindControl("myButton"), Button).Text = "New Text"
End Sub

0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 100 total points
ID: 17964551
There is a way, using a recursive function, to use FindControl to find a control by ID anywhere in the hierarchy.

Bob
0
 
LVL 33

Assisted Solution

by:raterus
raterus earned 100 total points
ID: 17968259
If you save the UniqueID of the button, say in the viewstate, when the page posts back, you can use Page.FindControl("Controls_Unique_ID") to get a direct reference to it.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now