Metodo IndexOf (ObjectListFieldCollection)

Restituisce l'indice del campo specificato in un oggetto ObjectListFieldCollection.

public int IndexOf(
   System.Web.UI.MobileControls.ObjectListFieldCollection field
)

Parametri

  • field
    Un campo da ricercare nell'insieme.

Valori restituiti

Restituisce l'indice del campo specificato come valore integer. Se il campo specificato non viene rilevato, il metodo IndexOf restituisce il valore –1.

Esempio

Nell'esempio seguente viene mostrato come utilizzare il metodo IndexOf per recuperare il campo Author di ObjectListFieldCollection.

 
 Sub CommandClick(sender As Object, e As ObjectListCommandEventArgs)
   
      ObjectList1.Fields.RemoveAt(ObjectList1.Fields.IndexOf("TaskName"))
      
      ' Associate the data source with the ObjectList control.
      ObjectList1.DataSource = CType(Session("MyArray"), ArrayList)
  
      ' Must bind again.
      ObjectList1.DataBind()
      ObjectList1.ViewMode = ObjectListViewMode.List
   
End Sub

[C#]

void CommandClick(Object sender, ObjectListCommandEventArgs e)
{
   ObjectList1.Fields.RemoveAt(ObjectList1.Fields.IndexOf("Author"));

   // Associate the data source with the ObjectList control.
   ObjectList1.DataSource = (ArrayList) Session["MyArray"];

   // Must bind again.
   ObjectList1.DataBind();
   ObjectList1.ViewMode = ObjectListViewMode.List;
}  

Vedere anche

Metodo IndexOf (IObjectListFieldCollection) | Metodo IndexOf (MobileListItemCollection) | Metodo IndexOf (ObjectListCommandCollection) | Metodo IndexOf (ObjectListItemCollection)

Si applica a: classe ObjectListFieldCollection