This documentation is archived and is not being maintained.
RepeaterItemCollection.Count Property
.NET Framework 1.1
Gets the number of RepeaterItem objects in the collection.
[Visual Basic] Public Overridable ReadOnly Property Count As Integer Implements _ ICollection.Count [C#] public virtual int Count {get;} [C++] public: __property virtual int get_Count(); [JScript] public function get Count() : int;
Property Value
The number of DataListItem objects in the collection.
Implements
Remarks
Use the Count property to determine the number of RepeaterItem objects in the RepeaterItemCollection collection. The Count property is commonly used when iterating through the collection to determine the upper bound of the collection.
Example
[Visual Basic] <!-- To see this snippet in the context of a complete example, see the RepeaterItemCollection class topic. --> . . . 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 [C#] <!-- To see this snippet in the context of a complete example, see the RepeaterItemCollection class topic. --> . . . 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>"; }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
RepeaterItemCollection Class | RepeaterItemCollection Members | System.Web.UI.WebControls Namespace | RepeaterItem
Show: