Recently someone entered my desk and asked the following:
“We have 2 lists: one with the holiday requests by users and one with remaining number of holiday hours for each user. When the responsible manager takes a look at the request (DispForm.aspx) he wants to see the number of remaining hours for that user. Can you do this?”
It all seemed very clear and easy, just connect 2 webparts. But it was a little more complicated.
To start I’ve made a copy of the DispForm.aspx page and called it DispFormExtra.aspx.
Next I added a DataView webpart and used the same list as datasource. I’ve hidden this datasource webpart because It will contain duplicate information and I use it only to connect to the extra webpart (with the number of holiday hours). When you add the dataview webpart you get all the items. I only wanted to see the current item so I used the Querystring parameter (ID) to filter it:
Now I added another dataview webpart and used the second list as datasource. That list contains one row for each user. I wanted to filter the dataview to show the row for the user who created the current item (Created By).
By connecting the first dataview with the second one. On the first dataview click “Web Part connections” and add a new connection. But first we add a parameter to the second dataview webpart to store the user who created the item in the first place.
I use this parameter in the next part: The webpart connection:
On the second dataview webpart we add a filter to show only the row for the user who created the item.
Now you save the page and try it in your browser.