Edit Webpart properties with dynamic dropdownlist

sharepoint-2010web-parts

I would like to Add a dropdownlist to edit webpart properties and bind it with all document library list available in sharpoint 2010.

Thank you for your Help.

Best Answer

You need to create Custom Web Part Editor with DropDownList

Creating a Custom Web Part Editor in SharePoint 2010

and using SharePoint Object Model to fill this dropdownlist like this (not tested):

SPListCollection docLibraryColl = SPContext.Current.Web.GetListsOfType(SPBaseType.DocumentLibrary);
foreach (SPList list in docLibraryColl) 
{
    SomeDropDownList.Items.Add(list.Title, list.Id);
}
Related Topic