Hello everybody,
I manually set a WinGrid's DataSource like this:
List<System.Data.Common.DbDataRecord> list = GimmeList();grid.DataSource = list;
Although list is != null and list.Count is > 0, no rows are shown in the grid. I've tried to use grid.Refresh() without success.
I'm sucessfully using a similar code snippet on the same grid with a List<T>, where T is an entity from my EF-edmx-model.
Does anybody know, why the List<DbDataRecord> behaves different from a List<T> in this situation?
Thanks in advance
Jan C. Potthoff
Hi Mike,
thanks for your answer and explaining the BindingManager,
I built a "mapping"-function for the List<DbDataRecord> that returns a List of Objects with the public properties, I want to display in the grid.
Thanks
Hi Jan,
When you bind to a list, the BindingManager in DotNet returns the properties of the object as the columns.
I'm not familiar with DbDataRecord, but I took a look at it and DbDataRecord only has one property on it - FieldCount, and it's read-only. So I would think the grid would show a single column with this property. I'm not sure why that's not showing up, but I assume that's not what you want, anyway.
You need to use a list of a type that has public properties on it in order use it for data binding. Or, you could create your own IBindingList class that returns the fields you want from the DbDataRecord.