Partager via


LookupColumn Element

The LookupColumn element functions similarly to the Column element and is only valid when referring to a Lookup field. The sole distinction between the Column and LookupColumn elements for Lookup fields is that LookupColumn retrieves the raw value of the column from the foreign list, while Column retrieves the raw value of the column in the local list.

Syntax

<LookupColumn
  HTMLEncode = "TRUE" | "FALSE"
  Name = "Text"
  ShowField = "Text"
  StripWS = "TRUE" | "FALSE"
  URLEncode = "TRUE" | "FALSE"
  URLEncodeAsURL = "TRUE" | "FALSE">
</LookupColumn>

Attributes

Name Description
HTMLEncode Optional Boolean. TRUE to convert embedded characters so that they are displayed as text in the browser. In other words, characters that could be confused with HTML tags are converted to entities.
Name Required Text. Specifies the name of the lookup column. Allows the LookupColumn element to be used outside the field rendering context by supplying an ID.
ShowField Optional Text. Specifies the field to be displayed in the list that is referenced through the Lookup field. If this attribute is not specified, the default is to display the value contained in the Title field.
StripWS Optional Boolean. TRUE to remove white space from the beginning and end of the value returned by the element.
URLEncode Optional Boolean. TRUE to convert special characters, such as spaces, to quoted UTF-8 format, for example, %c3%ab for character ë.
URLEncodeAsURL Optional Boolean. Like URLEncode, but TRUE to specify that the string to encode is a path component of a URL and not to encode the forward slash ("/").

Remarks

In the typical case of a Lookup field called LookupTitle that points to the title of item 1 in an announcements list, <LookupColumn Name="LookupTitle"/> would render "Get Started with Windows SharePoint Services!", while <Column Name="LookupTitle"/> would render "1". Consequently, in most situations involving Lookup fields, use the LookupColumn element instead of the Column element. The only time to use the Column element is when you need a raw reference to the ID of the item in the target list, perhaps for constructing your own link to the target item.

Example

The following example uses the LookupColumn element to return a value that is used in creating a complete URL for a page on the server.

<HTML><![CDATA[ <a href="  ]]></HTML>
<HttpHost URLEncodeAsURL="TRUE" />
<LookupColumn URLEncodeAsURL="TRUE" />
<HTML><![CDATA[ ">  ]]></HTML>