Metodo Add (ObjectListCommandCollection)

Consente di aggiungere un comando all'insieme.

public void Add(
   System.Web.UI.MobileControls.ObjectListCommand command
)

Parametri

  • command
    Il comando da aggiungere al termine dell'insieme.

Esempio

Nell'esempio seguente viene mostrato come utilizzare il metodo Add per aggiungere due comandi (Command1 e Command2) all'insieme ObjectListCommandCollection.

Dim Command1 As ObjectListCommand 
Dim Command2 As ObjectListCommand

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If Not IsPostBack Then
        
        Dim arr As ArrayList = New ArrayList()

        arr.Add(New Task("Verify transactions", "Done"))
        arr.Add(New Task("Check balance sheet", "Scheduled"))
        arr.Add(New Task("Send report", "Pending"))

        'Associate and bind the list to the array.
        ObjectList1.DataSource = arr
        ObjectList1.DataBind()

        Command1 = New ObjectListCommand("text1", "value1")
        Command2 = New ObjectListCommand("text2", "value2")
        ObjectList1.Commands.Add(Command1)
        ObjectList1.Commands.Add(Command2)

   End If
   
End Sub

[C#]

ObjectListCommand Command1;
ObjectListCommand Command2
;
public void Page_Load(Object sender, EventArgs e)
{
  
   If (!IsPostBack)
   { 
   ArrayList arr = New ArrayList();

   arr.Add(New Task("Verify transactions", "Done"));
   arr.Add(New Task("Check balance sheet", "Scheduled"));
   arr.Add(New Task("Send report", "Pending"));

   //Associate and bind the list to the array.
   ObjectList1.DataSource = arr;
   ObjectList1.DataBind();
   Command1 = new ObjectListCommand("text1", "value1");
   Command2 = new ObjectListCommand("text2", "value2"); 
   ObjectList1.Commands.Add(Command1);
   ObjectList1.Commands.Add(Command2);
}

Vedere anche

Metodo AddAt | Metodo Clear (Common) | Metodo Remove (ObjectListCommandCollection) | Metodo RemoveAt (Common)

Si applica a: classe ObjectListCommandCollection