Export (0) Print
Expand All

RepeaterItemCollection Class

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

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public sealed class RepeaterItemCollection : ICollection, IEnumerable
public final class RepeaterItemCollection implements ICollection, IEnumerable
public final class RepeaterItemCollection implements ICollection, IEnumerable
Not applicable.

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.

  • Use foreach (C#) or For Each (Visual Basic) to iterate throught 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.

      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();
}
      }

void Page_Load(Object Sender, EventArgs e)
{
    if (!(get_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.set_DataSource(myCollection);
         myRepeater.DataBind();
    }
} //Page_Load

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

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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft