Binding Grid to a Linq Datasource from Winforms (.net)?

Up vote 1 down vote favorite share g+ share fb share tw.

Back in the old days (i.e. Last month) I'd bind my winforms grid to a dataset and be off and running. By default the grid contents could be updated.

(similar to an Excel spreadsheet) But, if I bind a grid to a Linq datasource (either Linq to SQL or Linq to Entities) my winforms grid is locked into a read-only mode. How can I enable an update mode? .net winforms linq linq-to-entities grid link|improve this question asked Apr 14 '09 at 17:22Jeff1,71233176 98% accept rate.

Deleted my answer. Did some digging around in the DGV. Seems like it handles ILists and IListSource implementations differently than others.

These go into CurrencyManagers that are updatable and others go into PropertyManagers that are not. As to why ToList() fails I can't answer. Good luck.

– Will? Apr 14 '09 at 18:21.

I.e. Select new {Foo = order. Foo, Bar = custmoer.

Bar}; (or similar) - anonymous types in C# are immutable, so yes: it will seem read only. However, regular classes (either the LINQ-generated ones, or your own) should be editable. The only thing to remember is to call .ToList() on any query (rather than giving it the IEnumerable/IQueryable object).

Look at the GetNewBindingList method on the various classes for 'better' binding. And remember to call SubmitChanges when you are done.

Found the solution: use lamda expressions to filter the entity and bind directly to the entity.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions