I'm creating a webpart that aggregates a load of content from different lists throughout our site collection what I can't workout is how to get the exact link to each item. All I seem to get back is {site}/{listtitle}/1.000 how do I get this "1.000" to say "pagename.aspx?id=1", is this something I have to work out myself or is there a function to do this?
+2
A:
To get the ID of an item in a list you can use SPListItem.ID. Then you can just append it to the base URL that you want, e.g. "pagename.aspx?id=" + myitem.ID.
strongopinions
2009-11-17 16:30:41
A corollary to this: You can also see the ID for an item in the URL if you look closely... DispForm.aspx?ID=20 etc.
Goyuix
2009-11-17 20:43:07
+3
A:
How I do it:
string itemUrl = List.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl + "?id=" + item.ID;
Chloraphil
2009-11-17 20:55:13