Montag, 15. Dezember 2008

Using the SPListItem.Url property

If you are wondering in using the SPListItem.Url property, it is returning a value like http://localhost/Lists/MyList/2_.000

You cannot use this url for navigating in your web ui. To get a proper "web" url, you have to tailor your code a little bit differently to retrieve the correct path to the DispForm.aspx page or whereever you want to go:

SPList list = site.Lists.GetList("MyList");
SPListItem item = list.Items[id];
list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID;

Keine Kommentare:

Kommentar veröffentlichen