Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have 2 lists.

List1 (Customer) is populated with items.........

List2 (Orders) I am busy populating, in List2 I have a Hyperlink field (customer) which (should) link to List1

So when the user is browsing List2 (Orders) I want him/her to be able to click on the customer field link and get taken to the custom list item in List1 (Customer)

I'm using object model to populate List2, I'm trying this without luck:

// Items[0] = the SPListItem for my Customer List Item
SPListItem item = items[0];

item.Url.ToString(); // this returns - Lists/[MyOrderListName]/1735_.000

However setting the value of the order list item like this:

oListItem["PLANS"] = siteURL + customerLink + ", " + customerName;

Gives me: http://myServer.com/Lists/[MyOrderListName]/1735_.000]

This is not the correct url to the list item, so how can I format the link so it really points to the list item?

Thanks in advance

UPDATE: The short version

What is the URL for a list item in a list?

Because -

SPListItem item = items[0];
item.Url.ToString();

Does not produce a valid browsable link for the user.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

How about: http://site/web/list/DispForm.aspx?ID=[your item's ID] ?

share|improve this answer
    
Looks good, let me try it :) –  user879 Dec 22 '10 at 12:14
    
Works like a charm, and I spotted a dynamic way to get the display form URL (its relative) item.ParentList.DefaultDisplayFormUrl –  user879 Dec 22 '10 at 12:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.