none
How to navigate document listviewwebpart to a specific folder programmatically ?

    Question

  • Hi all,

     

    How can I navigate document listviewwebpart to a specific folder programmatically?

     

    I have one web page with a shared document listview webpart. I wish the webpart navigate to a specific folder when page is opened, rather than shared document's rootfolder. How can I do it?

     

    One workaround is specify url querystring Rootfolder="destination folder", but it is rather inconvenient. And if I put two document listview in the same page, both listview will navigate to same folder, but not display different folder respectively. 

    Sunday, February 24, 2008 5:07 AM

All replies

  • Did you figure this out, I  need to do the same thing.  Thanks!  Ed
    Wednesday, January 21, 2009 4:08 AM
  • I also need to do this, have either of you been successful?

    Thanks,
    Jacob
    Tuesday, March 03, 2009 12:03 PM
  • HI @ll

    here just one example, you should adapt it to your requirements. But i think, it answers your questions.....

    variable upFolder is a string containing the folder structure. lv is the listViewWebPart. Instead of the list.DefaultView you can also use the "actual" view of the ListViewWebPart with list.Views[new Guid(lv.ViewGuid)], website is the current web
     
    SPQuery query = new SPQuery { Folder = website.GetFolder(upFolder) };
    SPListItemCollection itemCol = list.GetItems(query);
    if (itemCol.Count > 0)
    {
    	lv.ListName = list.ID.ToString("B").ToUpper();
    	SPView view = list.DefaultView;
    	view.Query = query.Query;
    	view.Update();
    	lv.ViewGuid = view.ID.ToString("B").ToUpper();
    	lv.GetDesignTimeHtml();
    }
    				

    best regards

    Kristof

    • Edited by k.thomys Wednesday, August 05, 2009 2:31 PM
    Wednesday, August 05, 2009 2:23 PM
  • I,ve you just figure out that your example doesnt work? this instruction SPQuery query = new SPQuery { Folder = website.GetFolder(upFolder) }; cannot compile. do you know that?


    tha black chief with a bizzarre voice
    Wednesday, July 21, 2010 2:28 PM