次の方法で共有


RepeaterItemCollection クラス

Repeater コントロール内の RepeaterItem オブジェクトのコレクションを表します。このクラスは継承できません。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public NotInheritable Class RepeaterItemCollection
    Implements ICollection, IEnumerable
'使用
Dim instance As RepeaterItemCollection
public sealed class RepeaterItemCollection : ICollection, IEnumerable
public ref class RepeaterItemCollection sealed : ICollection, IEnumerable
public final class RepeaterItemCollection implements ICollection, IEnumerable
public final class RepeaterItemCollection implements ICollection, IEnumerable
適用できません。

解説

RepeaterItemCollection クラスは RepeaterItem オブジェクトのコレクションを表し、このオブジェクトは Repeater コントロールのデータ項目を順番に表します。プログラムにより Repeater コントロールから RepeaterItem オブジェクトを取得するには、次のメソッドのいずれかを使用します。

  • インデクサを使用し、配列表記を使ってコレクションから単一の RepeaterItem オブジェクトを取得します。

  • CopyTo メソッドを使用して、コレクションの内容を System.Array オブジェクトにコピーします。その後、このオブジェクトを使用して、コレクションから項目を取得できます。

  • GetEnumerator メソッドを使用して System.Collections.IEnumerator インターフェイスを作成します。その後、このインターフェイスを使用して、コレクションから項目を取得できます。

  • コレクションを反復処理するには、foreach (C#) または For Each (Visual Basic) を使用します。

Count プロパティは、コレクション内の合計項目数を指定します。通常は、コレクションの上限を判断するために使用されます。

使用例

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

.NET Framework のセキュリティ

継承階層

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

スレッド セーフ

この型の public static (Visual Basicでは共有) メンバはすべて,スレッド セーフです。インスタンス メンバの場合は,スレッド セーフであるとは限りません。

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

RepeaterItemCollection メンバ
System.Web.UI.WebControls 名前空間
RepeaterItem
Repeater
Repeater.Items プロパティ
CopyTo
GetEnumerator
Count