Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Find a Control in the footer of a repeater

Posted on 2006-11-17
3
Medium Priority
?
525 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 1200 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 400 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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

972 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