Prev | Current Page 388 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


284 CHAPTER 7 ?–  SE RVER CONTROL DATA B INDING
Figure 7-2. The Repeater control and its templates
The RepeaterItem Container Control
RepeaterItem is a building block used by the Repeater control to create its content. It is based
on the System.Web.UI.Control base class and serves as the primary container for instantiating
templates and working with events.
The following code snippet shows how the RepeaterItem control is declared, inheriting
from Control and implementing the INamingContainer interface to prevent name collisions on
child controls:
public class RepeaterItem : Control, INamingContainer
{
...
public RepeaterItem(int itemIndex, ListItemType itemType, object dataItem)
{
this.itemIndex = itemIndex;
this.itemType = itemType;
this.dataItem = dataItem;
}
...
...
}
The private data members are instantiated by the constructor. These fields are exposed as
public properties as well:
private object dataItem;
public object DataItem
{








































CHAPTER 7 ?–  SERVER CONTROL DATA B INDING 285
get
{
return dataItem;
}
set
{
dataItem = value;
}
}
private int itemIndex;
public int ItemIndex
{
get
{
return itemIndex;
}
}
private ListItemType itemType;
public ListItemType ItemType
{
get
{
return itemType;
}
}
ItemIndex exposes the relative position of the RepeaterItem control with respect to its siblings
underneath the parent Repeater control.


Pages:
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400