次の方法で共有


RepeaterItemCollection.Count プロパティ

コレクション内の RepeaterItem オブジェクト数を取得します。

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

構文

'宣言
Public ReadOnly Property Count As Integer
'使用
Dim instance As RepeaterItemCollection
Dim value As Integer

value = instance.Count
public int Count { get; }
public:
virtual property int Count {
    int get () sealed;
}
/** @property */
public final int get_Count ()
public final function get Count () : int
適用できません。

プロパティ値

コレクション内の DataListItem オブジェクトの数。

解説

Count プロパティを使用して、RepeaterItemCollection コレクション内の RepeaterItem オブジェクトの数を確認します。通常、Count プロパティは、コレクションを反復処理してコレクションの上限を確認する場合に使用されます。

使用例

このコード例の全体像については、RepeaterItemCollection クラスのトピックを参照してください。

Sub Item_Clicked(Sender As [Object], e As EventArgs)
   labelDisplay.Text = "Using item indexer.<br />"
   labelDisplay.Text += "The Items collection contains: <br />"
   
   ' Display the elements of the RepeaterItemCollection using the indexer.
   Dim myItemCollection As RepeaterItemCollection = myRepeater.Items
   Dim index As Integer
   For index = 0 To myItemCollection.Count - 1
      labelDisplay.Text += CType(myItemCollection(index).Controls(0), DataBoundLiteralControl).Text + "<br />"
   Next index
End Sub 'Item_Clicked
      void Item_Clicked(Object Sender, EventArgs e)
      {
labelDisplay.Text = "Using item indexer.<br />";
labelDisplay.Text += "The Items collection contains: <br />";

// Display the elements of the RepeaterItemCollection using the indexer.
RepeaterItemCollection  myItemCollection = myRepeater.Items;
for(int index=0;index < myItemCollection.Count;index++)
labelDisplay.Text += ((DataBoundLiteralControl)
   myItemCollection[index].Controls[0]).Text + "<br />";
      }
void Item_Clicked(Object Sender, EventArgs e) 
{
    labelDisplay.set_Text("Using item indexer.<br />");
    labelDisplay.set_Text(labelDisplay.get_Text() 
        + "The Items collection contains: <br />");

    // Display the elements of the RepeaterItemCollection using 
    // the indexer.
    RepeaterItemCollection myItemCollection = myRepeater.get_Items();
    for(int index=0;index < myItemCollection.get_Count();index++) {
        labelDisplay.set_Text(labelDisplay.get_Text() 
            + ((DataBoundLiteralControl)(myItemCollection.get_Item(
            index).get_Controls().get_Item(0))).get_Text() + "<br />");
    } 
} //Item_Clicked

プラットフォーム

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 クラス
RepeaterItemCollection メンバ
System.Web.UI.WebControls 名前空間
RepeaterItem