Overview | Methods | Fields | This Package | All Packages
Sets the bound member of the DataGrid control's underlying data source.
Syntax
public void setDataMember( String dataMember )
Parameters
dataMember
The name of the member of the underlying data source that is to be bound to the DataGrid control.
Remarks
To bind the DataGrid control to a recordset, first set the dataSource property to identify the data source associated with the control. A data source is an object that implements the IDataSource interface and exposes one or more recordsets. To specify which recordset is to be bound, set the dataMember property. For example:
/* Bind a DataGrid control to the recordset named
"Products", which is exposed by the data source, ds. */
dataGrid1.setDataSource(ds);
dataGrid1.setDataMember("Products");
If you do not call setDataMember, then the data source's default recordset will be bound. (You can explicitly specify the default recordset by setting the dataMember property to an empty string.)
/* Bind the control to the default recordset
exposed by the data source, ds. */
dataGrid1.setDataSource(ds);
dataGrid1.setDataMember(""); /* This line is optional. */
Note that the ADO Recordset and DataSource components already implement the IDataSource interface. Therefore, you can set the dataSource property directly to one of these components. In this case, you do not have to set the dataMember property:
/* Pass the Recordset component, rs, directly to
setDataSource without calling setDataMember. */
dataGrid1.setDataSource(rs);
See Also getDataMember, getDataSource