I have two tables. One that is a parent and the other that is a child. When a user clicks a row in the parent table, it sets the datasource for the child table to the associated children for that row. This is set up with Entity Framework with an ObjectContext. It works just great for existing data.
If I add a new row to the child table and populate it with values, it appears to work fine, but when I click on a different row in the parent table and then on the same parent row again, it doesn't show the child row I just created.
Do I specifically need to attach the child object to the ObjectContext when it is first created?
Hi Mike,
Thanks for the reply. I ended up going with a BindingList. For queries that return an IQueryable, I was able to set the data source to the result and it added new rows just fine. However, for queries that return an IEnumerable, it wouldn't work. Even if I called .AsQueryable() on the result. So for those, I had to extract the elements from the results and dynamically build a BindingList with them. And then have it associate any newly added items from the BindingList to their parent entities (and attach to the ObjectContext) when the data source changed. So it was two steps to get it working with the BindingList.
Hi,
IEnumerable<T> is not a good data source for the grid.
Does this work if you bind to any other Windows Forms control?
The WinGrid data source needs to be an IList or IBindingList.
The thing that I'm having the biggest problem with is binding the grid's data source to an object of type IEnumerable<T>. It doesn't complain, but it also doesn't show the columns or any of the rows. Do I need to handle results of this type in a special way to get them to bind correctly to the grid?