I'm programatically binding a DataGridView
's dataset to a List<MyType>
. I set the column names and types up in the designer:
When I first bind the list, after populating it, things look great:
But then when I re-bind the dataset to the list (to make it update after repopulating the list) the column names and types seem to be auto-generated from the property names (note the spaces disappear) and types:
My code when populating the List
looks like this:
GridView.DataSource = null;
ListOfItems.Clear();
Populate(ListOfItems);
GridView.DataSource = ListOfItems
I'm not very happy about this hacky way of resetting the binding but it doesn't seem to work otherwise, modifying the list contents doesn't refresh the view.
Is this a question of settings on the GridView, or do I need to modify my code?