I want to fetch all the list titles of the current site in a dropdown in my web part's editor part. Based on this selection I want to show list items in web part when Apply is hit.
My web part is deployed at site collections level.
Get the List title source:
public static IList<String> GetAllListTitle(SPWeb web)
{
List<String> title = new List<String>();
foreach(SPList list in web.Lists)
title.Items.Add(list.Title)
}
Have a look at these for how to implement dynamic dropdown as webpart property.
http://dev-tips.blogspot.in/2007/06/custom-property-of-webpart-dynamic.html
Use this code to populate the dropdown list.
SPWeb web = SPContext.Current.Web;
foreach(SPList list in web.Lists)
{
dropdownList.Items.Add(list.Title)
}