Search code examples
c#sharepointcustom-field-type

Save value of custom field type


I am new to SharePoint developement and have a few startup problems which I hope you will help me with.

I am trying to make a custom field type and I am using WPS builder to create the project. Right now I have the following files which are all compiling just fine :)

  1. SuperLookup3.cs
  2. SuperLookup3Control.cs
  3. SuperLookup3FieldEditor.cs
  4. SuperLookup3FieldEditor.ascx (controltemplate)
  5. fldtypes_SuperLookup3.xml (XML)

I have tried look at this example but I just can't get it to work.

My questions

  1. How is the relationsships between the files?

  2. I can see an override of UpdateFieldValueInItem() which is setting the value to the selected item of a dropdown list. But this method is never called (when debugging). How can this be?


Solution

  • Some general advice would be to post this question to the SharePoint Stack Exchange site (if this answer is unsatisfactory), since there are a lot more SharePoint developers there.

    From what I understand of that example, it seems to be quite a complex Custom Field Type to start with (given that it has multiple values). There's a good straightforward and pretty well explained tutorial on MSDN that you might want to try out: Walkthrough: Creating a Custom Field Type

    Here's a brief explanation of your files (and the classes they contain):

    1. This is the main class of your field, which derives from the SharePoint field base class (SPField). Your naming seems to indicate you're creating a lookup derivative; if so, you may wish to derived from SPFieldLookup.
    2. This is the class the creates the form control displayed on a list item's New, Edit, and Display forms (but not the List View). It's a go-between for the forms and the item's value for this field.
    3. &
    4. This is the section displayed on the Add/Edit Column page. I would expect 3. to have the ending '.ascx.cs' instead of '.cs', since it is the code-behind for 4.; which may be the cause of your problem. This control sets up your field; associating the class in 1. to the list.
    5. This is the field declaration. It says to SharePoint "Hey, I've created my own field; go look here to find it.", and directs SharePoint to the class in 1., which makes the field available on the Add Column page.