Solved

How to Find a Control in the footer of a repeater

Posted on 2006-11-17
3
510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Content Page 3 64
asp Google Map 2 92
asp.net open new page without popup blocker 8 56
I need help adding validation to my MVC.Net view 6 36
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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