I have a ListView that I am binding to a SPList. In this list view I would like to have a link to each SPListItem.
Microsoft has conveniently decided that the
URL member of an SPListItem should be a mysterious link that does not work. After some research I found some other people that had run into this and used the following work around:
listItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + listItem.ID
I attempted to shoe horn this into my ListView ItemTemplate and it almost works (using 0 instead of a PAGETYPE):
<ItemTemplate> <a id="a_ItemLink" href="<%# DataBinder.GetIndexedPropertyValue(((SPListItem)Container.DataItem).ParentList.Forms, ".Url") + "?ID=" + Eval("ID") %>" runat="server"><%# Eval("Title") %></a><br /> </ItemTemplate>
The issue that GetIndexedPropertyValue sets my links to something like this:
I'm not sure why it would include the
Microsoft.SharePoint.SPForm part, but obviously this is not working. Has anyone successfully DataBound to a SPListItem and extracted the URL? Am I doing something wrong above?