You will need to create Custom ToolPart to dynamically populate the dropdown values.You will need to create a class file in the WebPart and Inherit the ToolPart class and then create the dropdown and populate the dropdown and override the child controls and apply changes method of WebPart. Below is an example where i populated the DroppDown with all the Lists in the site.
class DropDownTool : Microsoft.SharePoint.WebPartPages.ToolPart
{
DropDownList ddlListProperties = new DropDownList();
protected override void CreateChildControls()
{
base.CreateChildControls();
this.Title = "Select List from DropDown";
Literal lit = new Literal();
lit.Text = "<br/><br/>";
Controls.Add(ddlListProperties);
Controls.Add(lit);
}
public DropDownTool(string _ddlValue)
{
SPListCollection listColl = SPContext.Current.Web.Lists;
foreach (SPList list in listColl)
{
ddlListProperties.Items.Add(list.Title);
}
if (!string.IsNullOrEmpty(_ddlValue))
{
ddlListProperties.SelectedValue = _ddlValue;
}
}
public override void ApplyChanges()
{
base.ApplyChanges();
Webpart_Assignment.Webpart_Assignment.dynamicValue = ddlListProperties.SelectedValue;
}
}