SPListItem URLs

There seems to be no built-in function or property to quickly return the correct URL for a SharePoint list item. The obvious property, SPListItem.URL, always returns an invalid URL along the lines of http://sharepoint/Lists/MyList/155_.000. Not ideal.

To get around this and return a correctly formatted web address, you can use the following code:

item.Web.Url + "/" + item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID

Leave a Reply

Your email address will not be published. Required fields are marked *