StrataFrame Forum

Accessing BusinessBindingSource Data

http://forum.strataframe.net/Topic31180.aspx

By Ger Cannoll - 5/2/2012

I am using a Devexpress grid with a BusinessBindingSource as the Source of the data linked to a SF BO. Most of the time this works fine. However, when I delete a Row, and I want to view an 'Unbound' field, I am getting errors. In Devexpress terms, an Unbound Field is where the Value is not directly in the table, but a Piece of Code is run to return the field. This code is put into a 'CustomUnboundColumndata' event .

When I run similar code, using a Bog Standard Windows BindingSource as the Data Source, data is returned fine, so I am assuming I am not taking care of some differences betwee the Windows BindingSource and the SF BuisnessBindingSource.

The code below runs fine using a Windows Binding Source , but when using te SF BusinessBidingSource, Null gets into the rowView, and so an error is thrown

private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)

        {

           GridView view = sender as GridView;

           if (e.Column.FieldName == "Unbound" && e.IsGetData)

           {

               IList source = view.DataSource as IList;

               DataRowView rowView =source[e.ListSourceRowIndex] as DataRowView;

               e.Value = rowView["FirstName"]+ "Test";

           }

        }

 

Anybody doing something similar with Devex (i.e. running CustomeUnboundColumnData event), or know how to amend the above in a SF BusinessBindingSource scenario

By Edhy Rijo - 5/2/2012

Hi Gerard,
I use DevExpress grids but I have not tried using an Unbound column, instead I create a Custom Field Property in the BO which will be shown as a column in the grid via the SF BindingSource.
Also I noticed that the DevEx grids don't like having SF BO properties with null values, so I had to return and Alternate value on Null via the BOM for each field.
Hope this help you in this case.
By Ger Cannoll - 5/2/2012

Hi Edhy. Thnaks for replying.

Initially  I had tried using Custom Field Properties but found for my purpose that Unbound Columns worked better, e.g. If I add a Row to the Grid, it automatically runs the unbound code populating the Lookup field without having to insert additional code. I also had some issues with the Custome Fields (Cant remember exactly what thy were now)  but decided on the Unbound Field as a more flexible alternative to polulate 'unbound' columns.

Also, I tend to avoid Null fields also

I think my problem here is that the Windows Binding Source is returning an Ilist which has the colums/row whereas perhaps the SF BusinessBindingSource returns someting different