Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Understanding the ProBindingSource : Programming considerations : Using the .NET DataMember property
Using the .NET DataMember property
In general, when you want to display child records in a separate control from the parent record, you create multiple ProBindingSources. You bind one ProBindingSource to the parent table's navigation query and bind a different ProBindingSource to each child's relation query, as shown below:
rCustBindS = NEW Progress.Data.BindingSource(dshdl:TOP-NAV-QUERY(1)).
rCustGrid:DataSource = rCustBindS.
rOrderBindS = NEW Progress.Data.BindingSource(dshdl:GET-RELATION(1):QUERY).
rOrderGrid:DataSource = rOrderBindS.
rOlineBindS = NEW Progress.Data.BindingSource(dshdl:GET-RELATION(2):QUERY).
rOlineGrid:DataSource = rOlineBindS.
However, you can use a single ProBindingSource for a ProDataSet and still display the child records in a separate control. After binding the ProBindingSource to the ProDataSet, you can set each control's DataMember property to point to the appropriate table, as shown below:
rCustOrdOLineBindS = NEW Progress.Data.BindingSource(dshdl, "ttCustomer").
rCustGrid:DataSource = rCustOrdOLineBindS.
rOrderGrid:DataSource = rCustOrdOLineBindS.
rOrderGrid:DataMember = "ttOrder".
rOlineGrid:DataSource = rCustOrdOLineBindS.
rOlineGrid:DataMember = "ttOrder.ttOrderLine".
In the example above, the ProBindingSource binds to a hierarchical set of tables starting at the top-level table, ttCustomer. The Customer grid binds to the ProBindingSource. Because the top-level table in the ProBindingSource is automatically assumed, the code does not need to specify the grid's DataMember. However, the code specifies the Order grid's DataMember as ttOrder, so that grid binds to the orders for the current customer. Similarly, the code specifies the OrderLine grid's DataMember as ttOrder.ttOrderLine, so that grid binds to the order lines for the current order.
Notice that in order to set the DataMember property, you must specify the full hierarchy of child tables. Also, when you are interested in the parent records, you do not set the DataMember property, since the ProBindingSource already binds directly to the top-level table.
Note: The OpenEdge GUI for .NET uses the DataMember property a little differently than other .NET implementations. You can set the DataMember property to the top-level table in .NET, but not in ABL.
Similarly, you can use a control's DataMember property to bind to a single field within a ProBindingSource bound to a ProDataSet, as shown below:
rCustOrdBindS = NEW Progress.Data.BindingSource(dshdl, "ttCustomer").
rComboBox1:DataSource = rCustOrdBindS.
rComboBox1:DataMember = "Order.SalesRep".
For a field in the top-level table, you can omit the table name, as shown below:
/* specifies "Name" field in ttCustomer table */
rComboBox1:DataMember = "Name".