title: DataBinding to List(Of CustomObject) in VB.NET
body: <p>I have been simple-binding the <code>Text</code> property of a <code>TextBox</code> for some time using a <code>DataTable</code> like so:</p>
  
  <pre><code>Dim dtbData As New DataTable
  
  ' populate table
  
  Me.BindingSource.DataSource = dtbData
  txtBox.DataBindings.Clear()
  txtBox.DataBindings.Add(New Binding("Text", Me.BindingSource, "OrderNumber", True))
  
  BindingNavigator1.BindingSource = Me.BindingSource
  </code></pre>
  
  <p>However, I am trying to change this to use a <code>List(Of CustomObject)</code> instead.  I am simply using the <code>dtbData</code> to populate the <code>List</code> and set the <code>DataSource</code> to the <code>List</code> instead.  I have set a breakpoint, and the <code>DataTable</code> and <code>List</code> are both populated.  If I comment out the line that adds the <code>Binding</code> to the <code>txtBox</code>, then the <code>BindingNavigator</code> works as expected, but if I leave it alone, the binding does not work.</p>
  
  <p>Here is what I've tried:</p>
  
  <pre><code>Dim lstData As New List(Of CustomObject)
  Dim dtbData As New DataTable
  
  ' populate table
  
  For Each row As DataRow In dtbData.Rows
      Dim obj As New CustomObject
  
      obj.OrderNumber = CInt(row("OrderNumber"))
      lstData.Add(obj)
  Next
  
  Me.BindingSource.DataSource = lstData
  txtBox.DataBindings.Clear()
  txtBox.DataBindings.Add(New Binding("Text", Me.BindingSource, "OrderNumber", True))
  
  BindingNavigator1.BindingSource = Me.BindingSource
  </code></pre>
  
  <p>It seems like it should work the same.  Instead of a <code>DataTable</code>, the <code>BindingSource</code> is a <code>List(Of CustomObject)</code> though, so I'm not sure if I have to do something differently.  The property names being bound are still the same.  I have also tried <code>Me.BindingSource.Current</code> in the <code>Binding</code> but that doesn't work either.  Can anyone tell me what I am doing incorrectly?</p>
  
  <p>The <code>CustomObject</code> looks like so:</p>
  
  <pre><code>Public Class CustomObject
      Public OrderNumber As Integer
  End Class
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I added a <code>Try</code>/<code>Catch</code> block around the binding, and I see the following error message: </p>
  
  <p><strong>Cannot bind to the property or column OrderNumber on the DataSource. Parameter name: dataMember</strong></p>
  
  <p>I just don't see what is different between binding to the <code>OrderNumber</code> column of a <code>DataTable</code> or the <code>OrderNumber</code> property of a <code>CustomObject</code>.</p>