RepeaterItemCollection.Item[Int32] 属性

定义

获取集合中指定索引位置的 RepeaterItem 对象。

public:
 property System::Web::UI::WebControls::RepeaterItem ^ default[int] { System::Web::UI::WebControls::RepeaterItem ^ get(int index); };
public System.Web.UI.WebControls.RepeaterItem this[int index] { get; }
member this.Item(int) : System.Web.UI.WebControls.RepeaterItem
Default Public ReadOnly Property Item(index As Integer) As RepeaterItem

参数

index
Int32

要从集合中检索的 RepeaterItem 的从零开始的索引。

属性值

RepeaterItem

在集合中,指定索引的 RepeaterItem 对象。

示例

若要查看完整示例上下文中的此代码,请参阅 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

注解

使用此索引器可以使用数组表示法从RepeaterItemCollection指定索引处获取RepeaterItem对象。

适用于

另请参阅