Share via


DataField Property

Sets or returns the name of the property from which to bind data. The value must be set to ensure data binding. The default value is an empty string ("").

public string DataField {
   get,
   set
}

Remarks

The property must be of a primitive type, or of type string, DateTime, Currency, or Decimal.

Example

The following example demonstrates how to use the DataField property to bind fields with the DataSource property for the Details view of the ObjectList control.

Class Book
   Private _BookName As String
   
   Public Sub New(BookName As String)
     
      _BookName = BookName
   
   End Sub
   
   Public ReadOnly Property BookName() As String
   
      Get
   
         Return _BookName
   
      End Get
   
   End Property

End Class
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
   'Add code for ObjectList data binding 
End Sub
</script>
<mobile:Form runat=server id="Form1" >
   <mobile:ObjectList runat="server" id="ObjectList1" >
       <Field Name="BookName" DataField="BookName" Title="BookName"/>
   </mobile:ObjectList>
</mobile:Form>  

[C#]
<script runat=server>
class Book
{
   private String _BookName;
   public Book(String BookName) 
   { 
       _BookName = BookName; 
   }
   public String BookName { get { return _BookName; } }
}
void Page_Load()
{
  // Add code for ObjectList data binding.
}
</script>
<mobile:Form runat=server id="Form1" >
   <mobile:ObjectList runat="server" id="ObjectList1" >
       <Field Name="BookName" DataField="BookName" Title="BookName"/>
   </mobile:ObjectList>
</mobile:Form>  

See Also

Applies to: ObjectListField Class