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

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="http://your.spdomain.com/{@FileDirRef.urlencodeasurl}/_layouts/listform.aspx?PageType=4&ListId={@ListId}&ID={@ID}">text</a>
  • 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

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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