Getting URL for item using GetSiteData in Sharepoint

2.3k views Asked by At

I'm using web.Site.MakeFullUrl((new SPFieldLookupValue(row["FileRef"] as string).LookupValue)) to get the URL to results in a GetSiteData query.

For some items this works fine, but for others I get results like http://server/Lists/My%20Message%20Board/Test/9_.000 - which always 404s. The urls always end in n_.0000.

Does anybody know why this is happening and how to get the correct URL?

2

There are 2 answers

0
Colin On

The items generating the weird url are not items in a Document Library that have a file associated with the actual SPListItem. The "normal" urls are urls to files in a doc lib, the weird ones are urls to items in a regular list. Just check for the type of item in the webpart / control / xsl to render the results.

If it is an item from a regular list (with the weird url), just replace it and make the url look like so:

http://server/Lists/My%20Message%20Board/Test/9_.000 should be:

http://server/Lists/My%20Message%20Board/Test/AllItems.aspx?ID=ITEMID

0
Toad of Toad Hall On

The advice above, by Colin, seems sound except for the fact that the 'good' url should reference Dispform.aspx. For example,

The URL,

http://server/Lists/My%20List/2%5F.000

Should be formatted like this:

http://server/Lists/My%20List/Dispform.aspx?ID=2