Databinding with EntityCollection

Posts   
 
    
tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 21-Feb-2007 20:50:00   

Environment: LLBLGenPro 2.0 - SelfServicing

I am databinding to an Infragistics UltraCombo component. I don't have any problems databinding using TypedLists, but databinding with EntityCollections is a problem. Below is a sample of my code. I don't get any error messages, but the program hangs on the "cboSelectInvoices.DataSource = invoiceHeaders;" statement. I know from the debugger that there are 113 records in invoiceHeaders. Any feedback would be appreciated.

          InvoiceHeaderCollection invoiceHeaders = new InvoiceHeaderCollection();
            SortExpression sorter = new SortExpression(InvoiceHeaderFields.InvoiceNo | SortOperator.Ascending);
            invoiceHeaders.GetMulti( null, 0, sorter, null);

              // Bind the combo to a data source. 
            cboSelectInvoices.DataSource = invoiceHeaders;
            cboSelectInvoices.DataMember = "";
JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 21-Feb-2007 21:34:38   

You should not need to set/reset DataMember, but be sure to set the ValueMember and DisplayMember properties.

tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 21-Feb-2007 21:46:23   

The ValueMember and DisplayMember properties are set immediately below this code sample, but they don't get executed as the program hangs.

tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 22-Feb-2007 05:27:27   

Some further info. The following code works, but I was hoping that I could databind the EntityCollection more directly with the UltraCombo.

           InvoiceHeaderCollection invoiceHeaders = new InvoiceHeaderCollection();
            SortExpression sorter = new SortExpression(InvoiceHeaderFields.InvoiceNo | SortOperator.Ascending);
            invoiceHeaders.GetMulti( null, 0, sorter, null);

             // Bind the combo to a data source. 
            DataTable dt = new DataTable();
            dt.Columns.Add(InvoiceHeaderFields.InvoiceNo.Name, InvoiceHeaderFields.InvoiceNo.DataType);
            dt.Columns.Add(InvoiceHeaderFields.InvoiceDate.Name, InvoiceHeaderFields.InvoiceDate.DataType);
            dt.Columns.Add(InvoiceHeaderFields.CustomerName.Name, InvoiceHeaderFields.CustomerName.DataType);
            DataRow dr;
            foreach (InvoiceHeaderEntity invoiceHeader in invoiceHeaders)
            {
                dr = dt.NewRow();
                dr[InvoiceHeaderFields.InvoiceNo.Name] = invoiceHeader.InvoiceNo;
                dr[InvoiceHeaderFields.InvoiceDate.Name] = invoiceHeader.InvoiceDate;
                dr[InvoiceHeaderFields.CustomerName.Name] = invoiceHeader.CustomerName;
                dt.Rows.Add(dr);
            }

         BindingSource bs = new BindingSource();
            bs.DataSource = dt;
            cboSelectInvoices.DataSource = bs;
            cboSelectInvoices.DataMember = "";
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 22-Feb-2007 07:57:55   

If you are using .NET 2.0, try to use: A BindingSource object (Windows App) Or an LLBLGenProDataSource (Web App)

tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 22-Feb-2007 14:08:56   

Walaa wrote:

If you are using .NET 2.0, try to use: A BindingSource object (Windows App) Or an LLBLGenProDataSource (Web App)

I did try to use a BindingSource, but I got the same results. I am reading between the lines that this is an issue specific to the interoperability between LLBLGenPro EntityCollections and Infragistics UltraCombo as everybody seems to agree that EntityCollections should be bindable.

The example that I provided where the EntityCollection data is written to a DataTable which is then linked to the UltraCombo does demonstrate that there is good data in the EntityCollection and that the UltraCombo does not have any issues with linking to a straight DataTable.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 22-Feb-2007 15:22:25   

Try to bind to the entityCollection.DefaultView

cboSelectInvoices.DataSource = invoiceHeaders.DefaultView;
tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 22-Feb-2007 16:12:22   

Walaa wrote:

Try to bind to the entityCollection.DefaultView

cboSelectInvoices.DataSource = invoiceHeaders.DefaultView;

I tried that. Same results.

I have also had the same behaviour when using the UltraWinGrid component.

I would be interested if anybody else is using Infragistics and has successfully used a EntityCollection as the DataSource for the UltraCombo or UltraWinGrid.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-Feb-2007 18:44:08   

The hang sounds familiar in the context of infragistics... Is there any maxbanddepth property on the combo, if so could you set it to 1? I fear infragistics simply reflects over the properties of the contents of the datasource IF it's not a datatable and reads property data to determine which columns to show, which is against the MS guidelines for databinding, they should simply use the ITypedList implementation as everyone else does.

Infragistics did implement ITypedList support some time ago, I'm not sure if you're using a version from infragistics which indeed has this.

Frans Bouma | Lead developer LLBLGen Pro
tedh
User
Posts: 34
Joined: 14-Dec-2006
# Posted on: 22-Feb-2007 19:03:27   

Otis wrote:

The hang sounds familiar in the context of infragistics... Is there any maxbanddepth property on the combo, if so could you set it to 1? I fear infragistics simply reflects over the properties of the contents of the datasource IF it's not a datatable and reads property data to determine which columns to show, which is against the MS guidelines for databinding, they should simply use the ITypedList implementation as everyone else does.

Infragistics did implement ITypedList support some time ago, I'm not sure if you're using a version from infragistics which indeed has this.

OK, this made all the difference in the world. Now everything works fine. I am using Infragistics 6.3 which is the most recent version. Is this problem something that I should be reporting to Infragistics and if so can I use you as the reference for any technical details?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-Feb-2007 20:25:16   

Sure simple_smile They can email to support AT llblgen.com if they need our assistence. My name is Frans Bouma.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-Feb-2007 11:03:11   

Handled further via email. Will report back here with the solution IF infragistics replies.

Frans Bouma | Lead developer LLBLGen Pro