Image Gallery for each List Item in SP 2010
February 21, 2013 Leave a comment
We were using a SharePoint 2010 List to store all details of various office events. One of the requirements was to store images (multiple) for each event / list item. We also needed to display all images for an event in the Display Form. The following approach was used to implement this.
We created a Picture Library to store the images related to all the List Items and added a Lookup Column for the Title of the List and an associated column to store the ID of the List Item. The lookup column of Title was added, so that users can associate the photos uploaded in the Picture Library by selecting the Title text, and do not have to go back to fetch the ID. Selecting the Title lookup, SharePoint 2010 will automatically populate the ID field.
Now, we created a custom display form for our Event List and added a XSLTListViewWebPart for the Picture Library. If you closely look the URL of the page which displays the List Item, SharePoint 2010 passes the ID field of the List Item as query string. We planned to filter the Picture Gallery in the Display form using the ID field from the query string. For this, you need to do the following :
- Open the Display Form in SharePoint Designer 2010
- Select the XSLTListViewWebPart and click on Options > Parameters and add a new parameter with type Query String and Query String Variable ID

- Next, click on Filter and add a Filter Criteria with the EventTitle:ID fields equal to the [ID] parameter added in Step 2 (above)

Thats all we need to display the pictures associated with a List Item in the Display form. We need to ensure the Event Title field is populated correctly for all the images uploaded to the Photo Library.


