Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Rows not shown when grid.DataSource is set to List<DbDataRecord>
posted

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

Parents
  • 469350
    Verified Answer
    Offline posted

    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.

Reply Children
No Data