Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Server Technologies
SDK Documentation
General Reference
Custom Field Types
 Custom Multicolumn Field Classes
Custom Multicolumn Field Classes

Windows SharePoint Services 3.0 contains a class, SPFieldMultiColumn, that emulates a field containing multiple values. In actuality, the class contains a single string value, in which the values of the various "columns" are separated by special delimiter characters. The class contains members that enable you to manipulate the class as if it contained multiple columns; for example, setting the number of "columns", and setting or retrieving the individual "column" values.

Classes derived from the SPFieldMultiColumn class, by default, inherit these members. In addition, derived classes can also take advantage of the Collaborative Application Markup Language (CAML) rendering patterns defined in the SPFieldMultiColumn class field definition XML. These rendering patterns are for display and header views of multicolumn data.

NoteNote:

In Windows SharePoint Services 3.0, data for SPFieldMultiColumn fields is stored in the content database as a non-sortable SQL data type. For that reason, columns based on the SPFieldMultiColumn field type or on custom field types derived from it are not sortable. However, you can overcome this limitation by using Custom Related Fields.

For more information about field definition XML and render patterns, see Custom Field Type Definition.

Accessing Data Values For SPFieldMultiColumn Objects

The SPFieldMultiColumn class contains a class, SPFieldMultiColumnValue, which represents the actual "column" values in the SPFieldMultiColumn object. The SPFieldMultiColumnValue class includes an index that developers should use to access the value of a specific "column", rather than directly parsing the results of the SPFieldMultiColumn.ToString method.

SPFieldMultiColumnValue Class Constructors

The SPFieldMultiColumnValue class includes three constructor methods. Developers can decide which constructor to use based on the following behavior:

  • SPFieldMultiColumnValue   Creates a new SPFieldMultiColumnValue object, without a set number of "columns". The developer can then use the SPFieldMultiColumnValue.Add method to append any number of "columns" of data necessary onto the object.

  • SPFieldMultiColumnValue   Creates a new SPFieldMultiColumnValue object with the specified number of "columns." Developers can then use the Item property to get and set the value of a specific "column."

  • SPFieldMultiColumnValue    Creates a new SPFieldMultiColumnValue object, using the passed-in string argument to determine the number of "columns" and the value in each. The string argument must begin and end with the delimiter characters ";#" and it must separate each field with them as well.

    For example, suppose you call this constructor, passing the following string:

    C#
    ";#column one value;#column two value;#column three value;#"
    

    The constructor creates a new SPFieldMultiColumnValue object with three "columns" of data. The first contains "column one value"; the second, "column two value"; and the third, "column three value".

    Developers can then use the Item property to get and set the value of a specific "column".

    This constructor is useful when reading the string from a database or other data source where the column values are stored with the delimiting characters already in place.

Writing Values from the SPFieldMultiColumnValue Class

Conceptually, the final SPFieldMultiColumnValue constructor performs the opposite function of the M:Microsoft.SharePoint.SPFieldMultiColumnValue.ToString method. The M:Microsoft.SharePoint.SPFieldMultiColumnValue.ToString method generates a string, complete with delimiting characters for "column" separation, from the SPFieldMultiColumnValue object. This method is useful when writing the "column" values to a database or other data source where the "column" values are stored as a string, with the delimiting characters already in place.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Default delimiter / Also found in beginning of string...      magalabastro   |   Edit   |  

The default delimiter is a semi-colon followed by a pound sign (;#).

This delimiter is also found in the beginning of the string value from SPFieldMultiColumnValue.ToString().

Tags What's this?: Add a tag
Flag as ContentBug
Bad Link to Constructor      S J ... Noelle Mallory - MSFT   |   Edit   |  
It appears that the link to the constructor with only a string parameter didn't get generated correctly ("M:Microsoft.SharePoint.SPFieldMultiColumnValue.#ctor(System.String)"). I assume that it should point to http://msdn2.microsoft.com/en-us/library/ms440470.aspx.
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker