RepeaterItemCollection.Count 屬性

定義

取得集合中 RepeaterItem 物件的數目。

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

屬性值

集合中 DataListItem 物件的數目。

實作

範例

若要在完整範例的內容中查看此程式碼,請參閱 RepeaterItemCollection 類別主題。

      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 />";
      }
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

備註

Count使用 屬性來判斷集合中的 RepeaterItemCollection 物件數目 RepeaterItem 。 在 Count 逐一查看集合以判斷集合的上限時,通常會使用 屬性。

適用於

另請參閱