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 通常在循环访问集合以确定集合的上限时使用。

适用于

另请参阅