PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

How to make a join between SP Lists

Posted by PANVEGA on March 22, 2008

Without writing some code, and that’s to build a “linked list” with two SharePoint List.  Sometimes you get a requirement to join two pieces of data within a SharePoint Site/Team Page, and in the past I’ve built connected Web Parts to do this, or created a single Web Part that pulled from both data-sources to make the data look as if it were one table/listing.

a) Customers (Title)
b) Orders (Title, and a lookup value called ‘Customer’ – which, you guessed it right, is a lookup on the Customer.Title SPColumn).

Here are my lists:

and

Great – now, this can be done on any ASPX, but to be clean and to the point, open the site in SharePoint Designer, and add a new ASPX – Untitled_1.aspx (that’s the default name).

1. In SPD, go to Data View –> Manage Data Sources

2. In the window that appears on the right, create a new Linked source as shown below:

3. Click on “Configure Linked Source” and go ahead and add both “Customers” and “Orders” and click “NEXT”

4. Make sure that you choose to Join the contents of the two data sources as shown below –

5. Give it a meaningful name such as “Customer-Orders” in the “General” tab.

6. Great, now while in the <form> tag in your ASPX, click on Data View –> Insert Data View, your UI should now say “Current Data Source – Customer – Orders” – “next insert fields to create a view”.

7. Now from the “Data Source Details” pane, select Customers.Title. and choose – Insert Selected Field as “Multiple Item View” as shown below:

Your ASPX should look like this –

8. Now place the cursor in front a particular value – Say “Scot Hillier”, and now in the Data Source Details Pane, Select Orders –> Title, and choose to insert as “Joined SubView” in the menu shown below:

Specify Join information as shown below:

9.   Thats it! Format it a little bit, run the ASPX – looks like this –

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: