Binding Data with the DataBinder Control

See Also

The DataBinder control binds a field from a recordset to the property of another control. When a property is bound, it is automatically set to the value of the field in the current record. The following procedures show how to bind the text property of an Edit control.

To associate the DataBinder control with a recordset

  1. Add a DataSource control to your form to retrieve the data. For information on how to do this, see Retrieving a Set of Records.

  2. Add an Edit control and a DataBinder control to the form.

    Note   Like the DataSource control, the DataBinder control is not displayed when the form is run, because it only manages the binding and does not actually display data.

  3. Select the DataBinder control on the form and set its dataSource property:

The bindings property of the DataBinder control identifies the bindings that have been currently defined. You can set this property using either the control's property page or its bindings editor.

To create the bindings using the property page

  1. Select the DataBinder control on the form. In the Properties window, click the Property Page toolbar button.

  2. In the Data Field drop-down list of the property page, select the name of the data field to be bound.

  3. In the Control drop-down list, select the name of the Edit control.

  4. In the Property drop-down list, select the text property.

  5. Click Add. The text property is now bound to the data field.

  6. To add other bindings, repeat the process. Click OK when all bindings have been added.

To create the bindings using the bindings editor

  1. Select the DataBinder control on the form. In the Properties window, click the bindings property and then click the ellipses (...) button.

  2. To add a binding in the bindings editor, click Add. (For each binding you want to add, click Add.)

  3. Click OK.

  4. In the Properties window, expand the bindings property. Each binding is listed by its index, which indicates the order in which the binding was added. (The index of the first binding is 0.)

  5. To define the binding, expand its indexed entry.

  6. Click fieldName. In the drop-down list, select the name of the data field to be bound.

  7. Click target. In the drop-down list, select the name of the Edit control.

  8. Click propertyName. In the drop-down list, select the text property.

Once you have created the bindings, you can add a DataNavigator control to the form to navigate the records. You can also apply a data format to bindings that display numerical, date, or boolean values.

For more information about the DataBinder control and for related programming examples, see DataBinder Component.