winforms - DataGridView become ReadOnly with Linq using c# -


i implementing system using c# ( windows forms ) entity frame work , linq.

the datagridview works when using normal linq statement, when used "join", datagridview become read , cant edit anything.

example: datagridview work statement :

var query = d in db.device select d;         dgvdevices.datasource = query.tolist(); 

but become non-editable query :

var query = u in db.users join d in db.device on u.id equals d.assignedto              select new { d.id, d.name, d.ownername,                          d.ownerphonenumber, d.details, user = u.name }; dgvdevices.datasource = query.tolist(); 

it because of nature of anonymous types read only.

anonymous types (c# programming guide)

anonymous types provide convenient way encapsulate set of read-only properties single object without having explicitly define type first.

to overcome limitation can create own class , shape output of query own class.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -