RepeaterItemCollection RepeaterItemCollection RepeaterItemCollection RepeaterItemCollection Class

定义

表示 RepeaterItem 控件中 Repeater 对象的集合。Represents a collection of RepeaterItem objects in the Repeater control. 此类不能被继承。This class cannot be inherited.

public ref class RepeaterItemCollection sealed : System::Collections::ICollection
public sealed class RepeaterItemCollection : System.Collections.ICollection
type RepeaterItemCollection = class
    interface ICollection
    interface IEnumerable
Public NotInheritable Class RepeaterItemCollection
Implements ICollection
继承
RepeaterItemCollectionRepeaterItemCollectionRepeaterItemCollectionRepeaterItemCollection
实现

示例

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

注解

类表示RepeaterItem对象的集合, 这些对象又表示Repeater控件中的数据项。 RepeaterItemCollectionThe RepeaterItemCollection class represents a collection of RepeaterItem objects, which in turn represent the data items in a Repeater control. 若要以RepeaterItem编程方式Repeater从控件检索对象, 请使用以下方法之一:To programmatically retrieve RepeaterItem objects from a Repeater control, use one of the following methods:

  • 使用索引器从集合中使用RepeaterItem数组表示法获取单个对象。Use the indexer to get a single RepeaterItem object from the collection using array notation.

  • 使用方法可将集合的内容复制System.Array到对象, 然后可以使用该对象从集合中获取项。 CopyToUse 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.

  • 使用方法创建一个System.Collections.IEnumerator接口, 该接口随后可用于从集合中获取项。 GetEnumeratorUse the GetEnumerator method to create an System.Collections.IEnumerator interface, which can then be used to get items from the collection.

  • 使用foreach (C#) 或For Each (Visual Basic) 来循环访问集合。Use foreach (C#) or For Each (Visual Basic) to iterate through the collection.

Count属性指定集合中的总项数, 通常用于确定集合的上限。The Count property specifies the total number of items in the collection and is commonly used to determine the upper bound of the collection.

构造函数

RepeaterItemCollection(ArrayList) RepeaterItemCollection(ArrayList) RepeaterItemCollection(ArrayList) RepeaterItemCollection(ArrayList)

初始化 RepeaterItemCollection 类的新实例。Initializes a new instance of the RepeaterItemCollection class.

属性

Count Count Count Count

获取集合中 RepeaterItem 对象的数量。Gets the number of RepeaterItem objects in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示是否可修改 RepeaterItem 中的 RepeaterItemCollection 对象。Gets a value that indicates whether the RepeaterItem objects in the RepeaterItemCollection can be modified.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

获取一个值,该值指示是否同步 RepeaterItemCollection 访问(线程安全)。Gets a value indicating whether access to the RepeaterItemCollection is synchronized (thread-safe).

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取集合中指定索引位置的 RepeaterItem 对象。Gets the RepeaterItem object at the specified index in the collection.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步 RepeaterItemCollection 集合访问的对象。Gets the object that can be used to synchronize access to the RepeaterItemCollection collection.

方法

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

RepeaterItemCollection 对象中的指定索引位置开始,将此 Array 中的所有项复制到指定的 Array 对象。Copies all the items from this RepeaterItemCollection to the specified Array object, starting at the specified index in the Array object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回可以循环访问 IEnumerator 中的所有 RepeaterItem 对象的 RepeaterItemCollection 接口。Returns a IEnumerator interface that can iterate through all the RepeaterItem objects in the RepeaterItemCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅