Upload document : Default value not applied on choice column if baseFieldControl.ControlMode = SPControlMode.Display

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/43643

Question

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.

Alex

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top