AutoGenerateFields Property

Specifies whether fields must be automatically generated from data. When enabled, each public property of the data becomes a field of the control. The default value is true.

public bool AutoGenerateFields {
   get,
   set
}

Remarks

When true, the object list handles the fields order in the ObjectListFieldCollection collection. When false, you must specify the order of the fields and set the DataItem property to bind to a data source.

Example

The following example demonstrates how to use the AutoGenerateFields property to statically associate the fields with their collection in the Details view of an ObjectList control.

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

   If Not IsPostBack Then
      ' Create and fill array.
      Dim arr As New ArrayList()
      arr.Add(New Task("Tomorrow's work", "yes"))
      arr.Add(New Task("Today's work", "yes"))
      ' Associate array to ObjectList.
      ObjectList1.DataSource = arr
      ' Fields collection will be generated automatically.
      ObjectList1.AutoGenerateFields = False
      ObjectList1.DataBind()
   End If

End Sub

<mobile:Form runat=server id="Form1" >
   <mobile:ObjectList runat="server" id="ObjectList1" >
     <Field Name="TaskName" DataField="TaskName" Title="TaskName"/>
     <Field Name="Editable" DataField="Editable" Title="Editable"/>
   </mobile:ObjectList>
</mobile:Form>

[C#]
public void Page_Load(Object sender, EventArgs e)
{
   if (!IsPostBack)
   {
      // Create and fill array.
      ArrayList arr = new ArrayList();
      arr.Add (new Task ("Tomorrow's work", "yes"));
      arr.Add (new Task ("Today's work", "yes"));
      // Associate array to ObjectList.
      ObjectList1.DataSource = arr;
      // Fields collection will be generated automatically.
      ObjectList1.AutoGenerateFields = false ;
      ObjectList1.DataBind();
   }
}
<mobile:Form runat=server id="Form1" >
   <mobile:ObjectList runat="server" id="ObjectList1" >
     <Field Name="TaskName" DataField="TaskName" Title="TaskName"/>
     <Field Name="Editable" DataField="Editable" Title="Editable"/>
   </mobile:ObjectList>
</mobile:Form>

See Also

Applies to: ObjectList Class