Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to put a ListViewWebPart on an Application Page.

I want to start the displayed document library in a specific folder, say "Folder 1".

I tried the following (as shown here):

ListViewWebPart lvWebPart = new ListViewWebPart
    {
        ChromeType = PartChromeType.None
    };

SPQuery query = new SPQuery { Folder = spWeb.GetFolder(folderPath) };

lvWebPart.ListName = list.ID.ToString("B").ToUpper();
SPView view = list.DefaultView;
view.Query = query.Query;

lvWebPart.ViewGuid = view.ID.ToString("B").ToUpper();
lvWebPart.ListViewXml = view.HtmlSchemaXml;

Controls.Add(lvWebpart);

The problem is that the listview always displays the list in the root folder. I just can't get to start the webpart in a sub folder. query.Query is null, but I still need to a assign a string value to view.Query - seems odd.

Could anyone tell me how I can start the WebPart in a specific folder? I also want to use the document librarie's upload button to upload to that folder then.

share|improve this question
The only thing working perfectly right now is to use a Querystring with RootFolder=myfolderpathhere, but do I have to use a querystring? – moontear May 22 '12 at 19:43

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.