.NET Framework Class Library RepeaterItemCollection Class Represents a collection of RepeaterItem objects in the Repeater control. This class cannot be inherited.

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
Public NotInheritable Class RepeaterItemCollection _
Implements ICollection, IEnumerable
public sealed class RepeaterItemCollection : ICollection,
IEnumerable
public ref class RepeaterItemCollection sealed : ICollection,
IEnumerable
[<Sealed>]
type RepeaterItemCollection =
class
interface ICollection
interface IEnumerable
end
The RepeaterItemCollection type exposes the following members.

Constructors

Methods

Extension Methods

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

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

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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.

See Also
|
Bibliothèque de classes .NET Framework RepeaterItemCollection, classe Représente une collection d'objets RepeaterItem dans le contrôle Repeater. Cette classe ne peut pas être héritée.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public NotInheritable Class RepeaterItemCollection _
Implements ICollection, IEnumerable
public sealed class RepeaterItemCollection : ICollection,
IEnumerable
public ref class RepeaterItemCollection sealed : ICollection,
IEnumerable
[<Sealed>]
type RepeaterItemCollection =
class
interface ICollection
interface IEnumerable
end
Le type RepeaterItemCollection expose les membres suivants.

Constructeurs

Méthodes

Méthodes d'extension

Notes
La classe RepeaterItemCollection représente une collection d'objets RepeaterItem, qui à son tour représente les éléments de données dans un contrôle Repeater. Pour récupérer par programme des objets RepeaterItem d'un contrôle Repeater, utilisez l'une des méthodes suivantes : Utilisez l'indexeur pour obtenir un seul objet RepeaterItem de la collection à l'aide d'une notation de tableau. Utilisez la méthode CopyTo pour copier le contenu de la collection vers un objet System..::.Array, qui peut ensuite être utilisé pour obtenir des éléments de la collection. Utilisez la méthode GetEnumerator pour créer une interface System.Collections..::.IEnumerator qui peut ensuite être utilisée pour obtenir des éléments de la collection. Utilisez foreach (C#) ou For Each (Visual Basic) pour itérer au sein de la collection.
La propriété Count spécifie le nombre total d'éléments dans la collection et est généralement utilisée pour déterminer la limite supérieure de la collection.

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

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0, 1.1, 1.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
|