Editing items inside Nested Document Libraries

I just found something pretty interesting about using a Data View Web Part to view items in a Document Library that contains folders. Without going into all the technical details, essentially the "Edit" link will return an "Item not found" error for any documents inside the subfolders.

If you ever see this error, and you are positive the item does exist, the most likely cause for error is that the URL does not contain the RootFolder attribute. As an additional side note, for some reason the DataView converts the EDIT link into the DISPLAY link, so there are two issues here that I will show you how to fix.

First, for the repro: Browse to the Shared Documents document library in the browser. Create a new document called docOne.doc. Create a new folder called FolderOne and browse to this folder. Create a new doc in this folder called docTwo.doc.

Next you want to open the site in FrontPage and create a new WebPart page. Then click Data..Insert WebPart. Choose the Shared Documents web part and insert it.

After it is inserted, right click it and choose List View Properties. Click Fields and add the Edit field. Then right click the List View and choose "Convert to XSLT Data View".

Save the page and preview in browser.

You should notice that if you click to edit docOne.doc, you see the Display form (which is wrong)

If you click to edit docTwo.doc, you will see an item doesn't exist error (which is also wrong)

So, back to FrontPage to fix this:

In code view for the page where the DataView lives, find:


<a href="{$URL_DISP}?ID={@ID}" onclick="GoToPage('{$URL_DISP}?ID={@ID}');return false;" target="_self">


And replace it with this:

<a href="{$URL_EDIT}?ID={@ID}&amp;RootFolder={@FileDirRef}" onclick="GoToPage('{$URL_EDIT}?ID={@ID}&amp;RootFolder={@FileDirRef}');return false;" target="_self">


That should do it. Have you seen other problems with Document Libraries? Let me know (the fact that the folders don't show up in the above scenario is already known and is unfortunately by design...)


Comments (0)

Skip to main content