2

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.

1 Answer 1

2

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

2
  • Looks good, let me try it :) Commented Dec 22, 2010 at 12:14
  • Works like a charm, and I spotted a dynamic way to get the display form URL (its relative) item.ParentList.DefaultDisplayFormUrl Commented Dec 22, 2010 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.