Share via


Differences Between ObjectList and List Controls

The ObjectList ASP.NET mobile control differs from the List control in ways portrayed in the following table.

Features ObjectList control List control
Data-bound Is strictly data-bound. The only way to add items to an object list is to bind the object list to a data source. Supports adding items statically, programmatically, and through data binding.
Multiple property view Allows you to view multiple properties, or fields, associated with each item. Depending on device characteristics, you can render the control as a table that displays more than one property of each object. Or you can provide a UI to allow the user to view additional properties of an object. Displays one property of each item.
Multiple item commands Allows you to associate multiple commands with each item. The set of commands for an item can be either shared among all items or unique to the item. Supports a default command for each item.
Custom pagination and templating Supported. Supported.

Note   The table compares the features of the ObjectList and List controls. However, it is important to understand that, although both controls support custom pagination and templating, the SelectionList class does not support pagination.

Specifying Field Elements Within an Object List

With an object list, you can display multiple fields for each item. Each field is associated with a property name. When a list item is bound to a data object, each field is bound to the corresponding property of the object. There are three ways to define a field:

  • Declaratively, using <Field> child elements within an object list.
  • Programmatically, by constructing ObjectListField objects and adding them to the Fields member collection of the control.
  • Automatically, by setting the AutoGenerateFields property to true.

See Also

Accessing Data Using Listing Controls