Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

How to Link Two Lists and Create a Combined Ciew in SharePoint 2010

, 10 May 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to join multiple lists together and create a combined View.

Using the method described in this post, you will be able to join multiple lists together and create a combined view. For example, assume that you are managing a list for some events. And you are having a separate participants list. You want to join the two lists and create a composite view.

SharePoint 2010 allows you to create this kind of view using a Linked Data Source. In this approach, you can create your own custom list in SharePoint.

How to Create a Linked Data source

Go to SharePoint Designer and go to the link called Data Sources.

image

Click the Linked Data Source button in the ribbon. SharePoint Designer will show this dialog:

In there, add the two lists that you wan to link together.

imageimage

I'm adding Airline schedule and Booking list. Those are the two list that I want to merge. Click Next and it will guide you through another screen. It will ask you to select either:

  • Merge
    • To combine lists which have the same column definition. This is like a Union operation in a database.
  • Join
    • Join operation is used to link two or more lists that need not have the same column definition. This is like a join operation in a database.

I need to join the two lists to get the passengers for a particular schedule. So I'm using the join option, and click Finish.

image 

Switch to the General tab and give some name to identify the data source.

image

Now you are done with the linked data source.

How to create a custom view using the linked data source in the SharePoint Designer

In here, I'm going to create a custom ASPX file in the SharePoint Designer and create a view on it. For that, go to SitePages and create a new ASPX file.

image 

In the designer, you can see an empty aspc file as follows:

image

Now you want to add the data source into the page. There are many ways to do this. The best thing is to go to Insert and then select your data source to add the data source to the page. But in this way, I found that it is not always visible in the data source task pane. You can then go to Data View and add your data source.

image

This action will generate a table in the page. But we don't need it. Do delete it. We will want the data source in the data source task pane (Select all and press Delete in the keyboard).

image

Now go to the task data source pane and select the columns you want to add to the page. Click Add as a multiple view item.

image

This will generate a table for you. Now click the right most column and go to the table and add a new column to the right in the table, as follows:

image

Now place the mouse cursor on the column and select the second list in the data source pane and select the columns you want, and click Join Sub View.

image

Then it will ask for the relation between the columns to Join (like the foreign key). In here, link data using the ID of the Airline schedule.

image

Note:– Some times Join Sub view does not appear. Then click two or more columns and then the view will appear. I don't know why this happens but it happened to me several times. This way, I manage to solve the issue.

Now you can see a composite list view in the page ..

image

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Melick

Sri Lanka Sri Lanka
No Biography provided

Comments and Discussions

 
QuestionNot prompted to set relationships PinmemberMember 1077522225-Apr-14 6:20 
QuestionI don't get the option to select a field to link the list and library PinmemberMember 104474905-Dec-13 6:49 
Bugformat data issue Pinmemberfirozhussain23-Nov-12 1:56 
QuestionThanks! This also works for MOSS/2007. Pinmemberkuke18-Jul-12 17:56 
QuestionHow to Link Two Lists and Create a Combined Ciew in SharePoint 2010 PinmemberDoo4fun16-Feb-12 10:57 
QuestionData Veiw Format Pinmembersvaa27-Jan-12 5:09 
GeneralTitle? PinmemberEdMan19610-May-11 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411019.1 | Last Updated 10 May 2011
Article Copyright 2011 by Melick
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid