Getting List Item URL in Sharepoint 2007
I'm creating a webpart that aggregates a load of content from different lists thr开发者_StackOverflow中文版oughout 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?
How I do it:
string itemUrl = List.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl + "?id=" + item.ID;
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.
精彩评论