Cannot Edit DataGridView when bound to custom LINQ query
-
Hello everyone and thank you all in advance for any help. I have the following problem. I bound a DataGridView to a Linq query that goes like this:
var _query = from p in _cntxt.Product
select new {p.Name, p.Provider.Name};dataGridView1.DataSource = _query;
The information is shown correctly, but I cannot edit any rows nor columns int he DataGridView I tried to specify each column to be ReadOnly = false; without success. If I change my query's select statement to simply:
select p;
It works and it allows the rows and columns to be edited. Can anyone help me?:confused: Thnx! -
Hello everyone and thank you all in advance for any help. I have the following problem. I bound a DataGridView to a Linq query that goes like this:
var _query = from p in _cntxt.Product
select new {p.Name, p.Provider.Name};dataGridView1.DataSource = _query;
The information is shown correctly, but I cannot edit any rows nor columns int he DataGridView I tried to specify each column to be ReadOnly = false; without success. If I change my query's select statement to simply:
select p;
It works and it allows the rows and columns to be edited. Can anyone help me?:confused: Thnx!The DataGridView will be in ReadOnly mode when you use anonymous types. So what I recommend is defining only those 2 columns in the DataGridView and set AutoGenerateColumns to false and go ahead and use select p;