asp.net.ph

Repeater.Controls Property

System.Web.UI.WebControls Namespace   Repeater Class


Returns the collection of child controls for a Repeater.

Syntax


Script [ ControlCollection variable = ] Repeater.Controls

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


variable Returns a ControlCollection object that represents the child controls of a Repeater.

Remarks

The Controls collection enables programmatic access to the child controls contained in a Repeater control. You can use this property to obtain information about each control in the collection.

For every header, footer, separator, and data item defined within the opening and closing tags of a Repeater, ASP.NET automatically adds one RepeaterItem object to the Controls collection.

In the case of data items, ASP.NET adds one RepeaterItem object to the collection for each record in the DataSource.

Any data-bound HTML tags or text strings that are not processed on the server, such as those defined for the ItemTemplate and AlternatingItemTemplate, are treated as DataBoundLiteralControl objects, and are added to the collection.

Any HTML tags or text strings that are not data-bound, such as those defined for the HeaderTemplate and FooterTemplate, are treated as LiteralControl objects, and are added to the collection as well.

Like most collections in the .NET Framework, you can add to, remove from, or iterate through the list of items in this collection.

Example

The below snippet shows how to programmatically access the collection of child controls ( as well as their child controls ) in a Repeater. In this case, the sample simply determines and displays the type and UniqueID of each child control.

Notice in the output that the first and last controls ( the header and footer items ) contain child literal controls, whereas the rest of the controls ( the data items ) contain data-bound literal controls.

foreach ( Control child in myRepeater.Controls ) {
   Response.Write ( child.GetType ( ) + " " + child.UniqueID + "<br>";
   foreach ( Control kid in child.Controls )
      Response.Write ( child.GetType ( ) + " " + child.UniqueID + "<br>";
   }
}

 Show me 

See Also

Repeater Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph