none
SPFieldMultiColumn inheritance problem RRS feed

  • Question

  • Hallo!

    I've got a problem with subj.
    I've created custom MultiColumn field with value formated as   ;#1;#SomeString;#
    It works fine.
    I've changed xml field definitions to change my field's presentation in lists, so my field look in lists as SomeString.

    The problem:
    when i go to "Site Content&Structure" of my site, and look at my list contents, I see my field values formated as "1, SomeString". And I have no idea how to remove "1, " part.
    please, help.

    Thursday, May 28, 2009 5:17 PM

Answers

  • Try overriding the GetFieldValueAsText and GetFieldValueAsHtml methods in your custom class.  Cast the parameter object to SPFieldMultiColumnValue and use its Item property to get each value by index.

    SPFieldMultiColumnValue myCustomValue = new SPFieldMultiColumnValue(Convert.ToString(value));
    return (myCustomValue.Count > 1) ? myCustomValue.Item[1] : string.Empty;

    should get you "SomeString" in your example.

    • Marked as answer by VlH Thursday, June 4, 2009 6:03 PM
    Friday, May 29, 2009 2:22 PM

All replies

  • What changes you have done in xml field definition. 
    Thursday, May 28, 2009 6:23 PM
  • Try overriding the GetFieldValueAsText and GetFieldValueAsHtml methods in your custom class.  Cast the parameter object to SPFieldMultiColumnValue and use its Item property to get each value by index.

    SPFieldMultiColumnValue myCustomValue = new SPFieldMultiColumnValue(Convert.ToString(value));
    return (myCustomValue.Count > 1) ? myCustomValue.Item[1] : string.Empty;

    should get you "SomeString" in your example.

    • Marked as answer by VlH Thursday, June 4, 2009 6:03 PM
    Friday, May 29, 2009 2:22 PM
  • No need to provide order number

     First option;Second Option;Third Option





    Regards
    Ashraf ul Islam
    Sharepoint Consultant

    Friday, May 29, 2009 2:28 PM
  • thank you! It is exactly what I needed.
    Thursday, June 4, 2009 6:02 PM