I created a new site column, a choice column with 5 values to pick from in a drop down list : 1, 2, 3, 4 (default value), 5

I then created a document content type using this column. The problem I am currently having is that when uploading a new document, I programmatically set the ControlMode of the baseFieldControl to SPControlMode.Display for certain users that should not be able to modify this column's value but should still be able to upload new document to the library. On the edit form, the value that is displayed is "4" which is normal as it is the defalut value, but once you save, if you go have a look the items properties, the saved value is "1". If you do the same test but using radio buttons it doesn't even save a value, not even the first one.

So basically all I want is to be able to set a field "readonly" on the edit form when adding a new document but I want the default value to be saved properly.

Thanks for any help you can provide on that issue.


1 Answer 1


If you want to use your BaseFieldControl with the Display Mode and set a value, you must set the value before setting the ControlMode.

You may find a different workaround Here

  • Hey thanks for answer. Unfortunately I also found that post while searching on the web but everything he mentions applies when you create a custom field in visual studio, which is not my case. I simply created a choice column in sharepoint 2010. And I override the CreateChildControls of the EditForm in order to set the ControlMode of certain fields. On that post, the code to solve this issue must be placed in the OnInit() of the custom field which I don't have. I just don't understand why the default value is not saved even if the field's controlmode is set to display.
    – Alex
    Commented Aug 17, 2012 at 16:10
  • Hi explanation is : "...when the field control mode is set to display on the new form .. the value of the PreviewValueTyped property of the related field is displayed......The source of the issue seems to be is that the ItemFieldValue property and the ListItemFieldValue property of the BaseFieldControl return the value of the PreviewValueTyped if the ItemId property is zero, that is the case for a new item." I think Event receiver can solve ur problem, on ItemUpdating if the ControlMode is Display for the BaseFieldControl then set the value 4 from code
    – Diptarag
    Commented Aug 17, 2012 at 16:23
  • That would make sense indeed! Thanks for the suggestion, I'll have a look at what I can do in ItemUpdating right now!
    – Alex
    Commented Aug 17, 2012 at 16:32
  • Please check and kindly let me know if it worked
    – Diptarag
    Commented Aug 17, 2012 at 16:43
  • I finally found a way to do it in ItemUpdating that I think wont screw the way things work when simply editing a document's properties. Here is what I did : SPListItem spListItem = properties.ListItem; foreach (SPField field in spListItem.Fields) { if (field.Type == SPFieldType.Choice && field.DefaultValue != null) { properties.AfterProperties[field.InternalName] = properties.BeforeProperties[field.InternalName] ?? field.DefaultValue; } } I still have a lot of testing to do as there are many cases that will run through this code, but I believe I am on the right track now.
    – Alex
    Commented Aug 22, 2012 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.