Lucy de Boer
 

Retrieve pageurl in SPSiteDataQuery

02

Jun

According to the web, using <FieldRef Name=\"EncodedAbsUrl\"/> is the way to retrieve the item url when using SPSiteDataQuery. However, for me (and others) this doesn't seem to work, only returning the root site url.
<FieldRef Name=\"ServerUrl\"/> appeared to be even more useless always returning only "/".
Appearantly this has something to do with the scope being used with SPSiteDataQuery.

However, you can still use <FieldRef Name=\"FileRef\"/>.
This will return a value like 7:#News/Pages/yourpage.aspx, and the last part is always server relative so useful enough. just chuck out what you don't need and make a url:

dr["EncodedAbsUrl"].ToString() + (new SPFieldLookupValue(dr["FileRef"] as string).LookupValue); }

---- edited to lookupvalue thanks to Keiths tip, thanks Keith ----

Share:

Lucy de Boer schreef

Comments (2)

Lucy de Boer

Zoeken

Categorie

Archief


Sign In