Share via


DataObjects Collection

InfoPath Developer Reference

Contains a DataObject object for each secondary data source used within a Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  Office System 2003

Remarks

Each DataObject object provides access to the particular data adapter object that was used to connect to the external data source.

The DataObjects collection implements properties that can be used to access a form's associated DataObject objects, and it is accessible through the DataObjects property of the XDocument object.

Bb229713.vs_note(en-us,office.12).gif  Note
The DataObjects collection can be used only to get the count of DataObject objects that it contains or to return a reference to a specified DataObject object. It cannot be used to create, add, or remove DataObject objects.

For more information about using the DataObjects collection, see Working with data in a form's underlying XML document and Working with data in a form's secondary data sources.

Example

In the following example, implemented as an OnClick event handler for a button on a form, the DataObjects property of the XDocument object is used to set a reference to the DataObjects collection. The code then loops through the collection and displays the positional index and name of each DataObject object that it contains:

JScript
  function ShowDataObjectNames::OnClick(eventObj)
{
   // Set a reference to the DataObjects collection.
   var objDataObjects = XDocument.DataObjects;

// Loop through the collection and display the name // of each DataObject object that it contains. for (i=0; i < objDataObjects.Count; i++) { XDocument.UI.Alert("Data object " + i + ": " + objDataObjects(i).Name); } objDataObjects = null; }

See Also