No data in dynamically created DataTable visible in WPF DataGrid

It took me some time to find out that you cannot have periods “.” in the column name of dynamically created DataTables. I would run the query, created the columns and add the rows to the table, but nothing would show in the DataGrid when I bound it.

I use the HQL interface from NHibernate a lot because it is not strongly typed and I can dynamically build a query and the DataTable to present. If you use HQL you will know that it uses dot notation to navigate to the correct class and property for selection.

After some time I decided to remove the period “.” from the column names using the String.Replace() method. And what do you know…the data became visible.

The biggest problem was that there was no exception or warning messages. Just no data was visible. This was a tough one and am writing it in hopes that is saves others some time.

DataGrid does not show data. Remove periods “.” from the column name if you are building your DataTable yourself.