Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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://social.msdn.microsoft.com/Forums/sharepoint/en-US/d52e2e1b-5938-43c0-9708-8d9d710880ae/custom-web-part-properties-in-sharepoint-2010-visual-web-partsdynamic-dropdown

http://dev-tips.blogspot.in/2007/06/custom-property-of-webpart-dynamic.html

share|improve this answer
add comment

Use this code to populate the dropdown list.

    SPWeb web = SPContext.Current.Web;
    foreach(SPList list in web.Lists)
    {
    dropdownList.Items.Add(list.Title)
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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