The context here is I use a special kind of DataSource for DataGridView, that is an anonymous type which can be created as follow:
var data = new[] { new { A = "A", B = 1 }, new { A = "B", B = 2 }, new { A = "C", B = 3 }};
The problem is if I use the above data source for a DataGridView, I can't edit the content of the DataGridView starting by clicking on its cells.
myDataGridView.DataSource = data;
Could you please explain to me why and how to make it editable? Or simply we can't make it work that way?
Your help would be highly appreciated.
Its because var data is anonymous type. And anonymous type properties are read-only.
I am not 100% sure about this but I think that you can't edit the grid because you are binding an anonymous type. Anonymous types cannot be changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With