Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

SPField.FieldReferences property

Gets a string array that contains the internal names of fields that are referenced in a computed field.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
public string[] FieldReferences { get; }

Property value

Type: []
Returns String.

The following code example displays the internal names of fields that involve field references.

The example assumes the existence of an .aspx page that contains a label control.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

SPSite oSiteCollection = SPContext.Current.Site;
SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"];
SPFieldCollection collFields = oWebsite.Lists["List_Name "].Fields;

for (int intIndex=0; intIndex<collFields.Count; intIndex++)
{
    string[] strRefFields = collFields[intIndex].FieldReferences;

    if (strRefFields != null)
    {
        for (int intStrPos=0; intStrPos<strRefFields.Length; intStrPos++)
        {
            Label1.Text += SPEncode.HtmlEncode(strRefFields[intStrPos]) + "<BR>";
        }
    }
}
oWebsite.Dispose();
NoteNote

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.