Version

About Data Items and Data Records

The DataRecord object’s DataItem property is a reference to the data item that the record represents. It should be an easy task to retrieve a reference to your data item if you already have a reference to a DataRecord object.

On the other hand, if you have a reference to your data item, finding the corresponding DataRecord object could be a complex recursive procedure. Fortunately, the DataPresenter family of controls exposes a GetRecordFromDataItem method that can return a DataRecord object that corresponds to your data item. You should keep in mind that this method starts searching for the record at the root level working its way down to the descendants until it finds a match. Therefore, calling the GetRecordFromDataItem method may be an expensive procedure if you have a deeply nested data source.

The following example code demonstrates the usage of the GetRecordFromDataItem method.

In Visual Basic:

Imports Infragistics.Windows.DataPresenter
...
'TODO: Replace 'YOUR_DATA_ITEM' with an actual reference to your data item.
Dim record As DataRecord = Me.xamDataPresenter1.GetRecordFromDataItem(YOUR_DATA_ITEM, True)
If record IsNot Nothing Then
    'TODO: Add logic for the record here
End If

In C#:

using Infragistics.Windows.DataPresenter;
...
//TODO: Replace 'YOUR_DATA_ITEM' with an actual reference to your data item.
DataRecord record = this.xamDataPresenter1.GetRecordFromDataItem(YOUR_DATA_ITEM, true);
if(record != null)
{
    //TODO: Add logic for the record here
}