Export (0) Print
Expand All

RepeaterItemCollection Class

Represents a collection of RepeaterItem objects in the Repeater control. This class cannot be inherited.

For a list of all members of this type, see RepeaterItemCollection Members.

System.Object
   System.Web.UI.WebControls.RepeaterItemCollection

[Visual Basic]
NotInheritable Public Class RepeaterItemCollection
   Implements ICollection, IEnumerable
[C#]
public sealed class RepeaterItemCollection : ICollection,
   IEnumerable
[C++]
public __gc __sealed class RepeaterItemCollection : public
   ICollection, IEnumerable
[JScript]
public class RepeaterItemCollection implements ICollection,
   IEnumerable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

The RepeaterItemCollection class represents a collection of RepeaterItem objects, which in turn represent the data items in a Repeater control. To programmatically retrieve RepeaterItem objects from a Repeater control, use one of the following methods:

  • Use the indexer to get a single RepeaterItem object from the collection using array notation.
  • Use the CopyTo method to copy the contents of the collection to a System.Array object, which can then be used to get items from the collection.
  • Use the GetEnumerator method to create an System.Collections.IEnumerator interface, which can then be used to get items from the collection.

The Count property specifies the total number of items in the collection and is commonly used to determine the upper bound of the collection.

Example

[Visual Basic] 
Sub Page_Load(Sender As Object, e As EventArgs)
   If Not IsPostBack Then
      Dim myDataSource As New ArrayList()

      myDataSource.Add(New PositionData("Item 1", "$6.00"))
      myDataSource.Add(New PositionData("Item 2", "$7.48"))
      myDataSource.Add(New PositionData("Item 3", "$9.96"))

      ' Initialize the RepeaterItemCollection using the ArrayList as the data source.
      Dim myCollection As New RepeaterItemCollection(myDataSource)
      myRepeater.DataSource = myCollection
      myRepeater.DataBind()
   End If
End Sub 'Page_Load

[C#] 
void Page_Load(Object Sender, EventArgs e)
{
   if (!IsPostBack)
   {
      ArrayList myDataSource = new ArrayList();

      myDataSource.Add(new PositionData("Item 1", "$6.00"));
      myDataSource.Add(new PositionData("Item 2", "$7.48"));
      myDataSource.Add(new PositionData("Item 3", "$9.96"));
      
      // Initialize the RepeaterItemCollection using the ArrayList as the data source.
      RepeaterItemCollection myCollection = new RepeaterItemCollection(myDataSource);
      myRepeater.DataSource = myCollection;
      myRepeater.DataBind();
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web (in System.Web.dll)

See Also

RepeaterItemCollection Members | System.Web.UI.WebControls Namespace | RepeaterItem | Repeater | Items | CopyTo | GetEnumerator | Count

Show:
© 2014 Microsoft