Print Page | Close Window

DevExpress grid binding

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
Printed Date: 22-May-2018 at 4:02am

Topic: DevExpress grid binding
Posted By: stevenr
Subject: DevExpress grid binding
Date Posted: 21-Feb-2012 at 11:10am

I've seen this behavior off and on but could never reproduce it consistently until now. It appears to happen only when using the IdeaBlade DevForce Classic XtraGridBindingManager control to communicate with a database through the IdeaBlade layer. However, the problem does *not* appear to be with IdeaBlade because I can see that the proper data is looked up in memory but it is just not being displayed correctly on the screen.

What I'm trying to do is to display the contents of a master table and one column of a detail table inside one grid. Because a one-to-many relationship exists in the database between the master and the detail tables, that grid column is formatted as a LookupEdit column.

To repro:
 1. Create a new database named gridbindingbug on the default local instance of SQL Server 2008 and run the attached script.sql file. This script creates a table Master and a table Details and populates them with the necessary data.
 2. Build and run the solution. When the application window shows, you will see one or more cells of the Details column in the grid show up empty.

When I tried to reproduce this scenario with XML datasets, the grid worked properly. At first I thought that the problem was with the DevExpress grid control because after all I can see the correct data in memory. So I posted a question on the DevExpress forum. As you can see, however, they referred me back to IdeaBlade, which now leads me to believe that the problem is with the binding manager that you developed for DevExpress: -


Thank you for the attached project. It helped me reproduce this problem. The issue is caused by the fact that GridControl cannot correctly operate complex data types as in case of the Detail class. To operate these data types, I suggest you use unbound columns (ms-help://DevExpress.NETv11.2/DevExpress.WindowsForms/CustomDocument1477.htm). If you do not want to use them, I suggest you contact the IdeaBlade support team to resolve this problem.

I have tried to follow their suggestion of using unbound grid columns, but that's not working either.

http://uploads/627/ - uploads/627/

Posted By: kimj
Date Posted: 21-Feb-2012 at 5:31pm

The problem here is in the Master-Detail relationship, which should be a 1:m, where one Master can have many Details. The relationship as defined in the ORM is somewhat reversed, with a Detail having many Masters, although that's not causing the problem.

If you profile this sample (I used SQL Profiler) you'll see a query executed to fulfill the Master.Detail navigation property for every Master record. The query is basically something like "select * from Detail where masterid = n". The query isn't constrained by locale, and with the data in these tables will return 2 detail records for every master. The order in which these records are returned and processed by DevForce is undefined, so if aMaster.Detail ends up being in the list of Details then it will be displayed, otherwise it's blank.
One way to fix this is to use a custom property on Master which contains an EntityQuery to select the one detail record for the master and locale wanted.

Posted By: stevenr
Date Posted: 05-Mar-2012 at 11:02am
OK, I think I have it working now. Thank you for you insight.

Print Page | Close Window