views:

127

answers:

2

I'm trying to make a custom property for a WebPart. The custom property should be a drop down with choices coming from a "choice" column from a content type. Is that even possible?

+1  A: 

Hi

You have two options:

1) If your choices will never change then you can hardcode an enum with these values and use that as datatype for your custom property. SP will the automatically generate a drop down.

2) If you can't hardcode the values then you have to implement what is called an EditorPart where you can code the UI for handling entry of the custom property

Per Jakobsen
+1  A: 

You cannot data bind directly to a content type column as it does not exist as in a bindable form, only as an XML secification on the content type itself.

Better to specify the column as a lookup and databind to the list directly. However, that is not going to work well when you only want one lookup across multiple webs or site collections.

In that case create a list in a config site such as http://intranet/sites/config and code a lookup control to databind to that list. Then use the control in the webpart and in a custom field control on the content type.

A bit of work, but worth it if you require SharePoint edit control (versioning, security etc) access to the contents of the lookup and a single (changeable) source of data across the entire site.

Nat