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've setup a DataFormWebPart which aggregates tasks from subsites. The user doesn't only want to view the tasks, there should be an option to edit / open them as well. So I need a way to at least construct a hyperlink to the task.

The incoming data from my sharepoint datasource features fields like FileRef, FileDirRef, ID and such.

Combining these makes it possible to construct something like: /sites/test/4/Lists/Tasks/../../_layouts/listform.aspx?PageType=4&ListId=627D073D-30F2-480F-AE84-E04115B7A955&ID=2

Using the XSL / XML fields like this: /{substring-after(@FileDirRef, '#')}/../../_layouts/listform.aspx?PageType=4&ListId={@ListId}&ID={@ID}

But in my humble opinion that sucks. It assumes the task list is always 2 levels deep from it's parent web (hence the ../../), which it might not be. So I'm looking for a better way to do it. I can't just call listform.aspx on the current site; since I'm rolling up data from subsites.

I checked the ddwrt namespace, but there doesn't seem to be anything helpful there. Who has got a nice solution for this (don't assume I'm the first one trying this).

To clarify some more. I want to display a webpart which:

  • Rolls up tasks from all subsites
  • Displays the tasks, their statuses, etc.
  • Displays the name of the web their on
  • Contains a link to the tasks display and/or edit form
share|improve this question

You shouldn't need to use the /../../ method if you are directing to a _layouts page. You could simply do it as (not fully tested, going from memory):

<a href="{@FileDirRef.urlencodeasurl}/_layouts/listform.aspx?PageType=4&ListId={@ListId}&ID={@ID}">text</a>
share|improve this answer
My datasource doens't provide that .urlencodeasurl field, where does that come from? – Jasper Jun 20 '12 at 7:25
I noticed it seems to be provided when you query the list directly from a dataform webpart. But when using a SPDataSource, it's not there. – Jasper Jun 20 '12 at 8:28
up vote 1 down vote accepted

This is what you'll need using ID's: CopyUtil.aspx (what's in a name, right?)

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.