views:

917

answers:

3

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?

+1  A: 

Are you perhaps using an anonymous type in the projection? 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<T>/IQueryable<T> object).

Marc Gravell
+1  A: 

Look at the GetNewBindingList method on the various classes for 'better' binding.

And remember to call SubmitChanges when you are done.

leppie
A: 

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

Jeff