RepeaterItemCollection.Count 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合中的物件數量 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屬性來決定集合中的RepeaterItem物件數量RepeaterItemCollection。 此 Count 性質常用於遍歷集合以確定集合的上界。