DataSource, ValueMember and DisplayMember Order Issues

April 23, 2008

For two times in a row this week I was asked to do a buddy check of .NET code that performs databinding. I found out that the order of the binding operations is very important:

  • Set the DisplayMember and/or ValueMember first
  • Set the DataSource property after that

You will avoid many exceptions this way ;-)

RESOURCES
Scott McMaster at CodeProject has more information regarding this weird databinding Windows Forms issue.


Profile picture

Written by Edin Kapić Insatiably curious code-writing tinkerer. Geek father. Aviation enthusiast. Cuisine journeyman. Follow me on Twitter