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?

1 Answer 1


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 =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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