I'm programming a Web Part in Visual Studio 2010 with SharePoint 2010. It will post content that users choose from the configurable part when you click on "edit web part". I want add a drop down list in the configurable part that will show titles from a list. Based on their choice it will display content from that list from another filed associated with that title.

I already know how to let users enter custom content in the configuration part and let it show up in the web part. I'm really interested from the point of creating that drop down list.



I believe you have a property of type string which represents the title from a list but SharePoint would render a text box instead of a dropdown containing list of titles.

SharePoint by default renders textbox for Web Part property of type string but that behavior can be modified by creating and associating a custom editor part for that property. The links below should help you;


http://code.msdn.microsoft.com/SharePoint-2010-Creating-a-b36c1597 (Code Sample)


| improve this answer | |
  • Alternatively, you can use a ToolPart which is the SharePoint flavor of EditorPart. – Kit Menke Jan 9 '12 at 15:42

This post will be great for you. In you case you should bind title of SPList as text and ID of SPList as value to drop down box. In web part property you should store ID of SPList and use this ID in your load data method.

I updated my answer. In this post the list items are binded to a drop down box. You can do your issue in the same approach, only bind your lists.

| improve this answer | |
  • Not sure if he wants to use web part connections for this? As I understand it, he wants a custom dropdown list in the web part edit pane. – Kit Menke Jan 9 '12 at 15:40
  • Sorry, I put incorrect url (((( this url is correct sharepointlessons.blogspot.com/2009/04/… – Alexander Jan 9 '12 at 15:46
  • Can you edit your answer to include the correct link? Then, we can delete these comments. :) – Kit Menke Jan 9 '12 at 15:51
  • Both of those links were helpful in creating a drop down. That's where I wanted to start. Now I need to put that drop down in the "configurable" side of the web part so that users can choose a title and the web part would display the body associated with that title. Thank you! – George Jan 9 '12 at 19:01
  • Final user experience would be: Edit Web Part -> Select "Title" from drop down in configuration -> Web Part Content shows the "Body" associated with the Title in that list. – George Jan 9 '12 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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