This documentation is archived and is not being maintained.

DefaultCommand Property

.NET Framework 1.1

Sets or returns the name of the default command.

public string DefaultCommand {


When set, the ObjectList control attempts to render a shortcut to invoke the default command. In HTML, the default rendering in ListView displays the first field as a link to the DetailsView of the ObjectList control. By setting the DefaultCommand property, clicking the link invokes the default command. Invoking the default command raises the ItemCommand event. The CommandName of the ObjectListCommandEventArgs object is set to the value of the DefaultCommand property.

Even if a default command is defined, you should include a command with the same name in the commands collection. If the control cannot render a graphical element that includes a shortcut for the default command, the default command is still available through the rendering of the ObjectList CommandsCollection.


The following example demonstrates how to use the DefaultCommand property to specify "Check" as the default command"".

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.DefaultCommand = "Check"

End Sub

Sub SelectCommand(sender As Object, e As ObjectListCommandEventArgs)
   If e.CommandName.ToString() = "Check" Then
      ActiveForm = Form2
      If e.CommandName.ToString() = "Browse" Then
         ActiveForm = Form3
      End If
   End If
End Sub
public void Page_Load(Object sender, EventArgs e)
   ObjectList1.DefaultCommand = "Check";
void SelectCommand(Object sender, ObjectListCommandEventArgs e)
   if (e.CommandName == "Check")
      ActiveForm = Form2;
   else if (e.CommandName == "Browse")
      ActiveForm = Form3;

<mobile:form id="Form1" runat=server >
  <mobile:ObjectList runat="server" id="ObjectList1" 
  <Command Name="Check" Text="Check Appointments" />
  <Command Name="Browse" Text="Browse Tasks" />

See Also

Applies to: ObjectList Class