SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a repository of files... I'd like to create a ListView Webpart wich receives the path in the tree and show the files in the document library... It's possible to do this by code? Is there any tutorial? The only way is to derivate a new class from ListViewWebPart wich receives parameters or it is possible to do this in a easy way?

share|improve this question
up vote 1 down vote accepted

It's not possible to extend a ListView Webpart, so i create a base webpart and inserted in this "container" a ListView WebPart..

This get parameters directly from the url / parameters and select the list this way!

Take a look =)

public partial class VisualWebPart1UserControl : UserControl
    private Microsoft.SharePoint.WebPartPages.ListViewWebPart myListView;
    protected override void CreateChildControls()
        SPSite oSiteCollection = SPContext.Current.Site;
        string listName = Context.Request.Param["List"];
        SPWeb oWebSite = SPContext.Current.Web;
        myListView = new Microsoft.SharePoint.WebPartPages.ListViewWebPart();
        myListView.Visible = true;
        myListView.EnableViewState = true;
        SPList list = oWebSite.Lists[listName];

        myListView.ListName = list.ID.ToString("B").ToUpperInvariant();
        myListView.TitleUrl = list.DefaultViewUrl;
        myListView.WebId = list.ParentWeb.ID;

        myListView.ListId = (System.Guid)list.ID;
        myListView.ViewGuid = list.DefaultView.ID.ToString("B").ToUpperInvariant();

        myListView.HelpMode = WebPartHelpMode.Modeless;


Hope this will help someone =)

share|improve this answer

Your Answer


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.