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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -