Create a Polling Web Part with SharePoint Designer and the DVWP
Guest Author: PatCharles Iovanella
As a continuation of my Best of EUSP article I was asked to expand on the Polling Data View Web Part. As I stated in my article, “SharePoint surveys leave a lot to be desired, especially from the end user perspective. What if you want to ask only one question and do not want users to leave the current page? A SharePoint survey is not the answer. But you can use the SharePoint survey and create a custom polling web part via SharePoint Designer and the Data View Web Part. You can turn a one question SharePoint survey into a cool looking Polling Web Part.”
So let’s get to it! I’m making a few assumptions that you know how to use SharePoint Designer and are able to complete all the steps without any further elaboration.
- Create your one question SharePoint survey
- Create a new Demo page using the Web Part Page template. This page will be our sandbox for building the polling web part.
- Open SharePoint Designer and then open your new Demo page
- Click into any Web Part Zone
- Insert Data View Web Part- Data View - Insert Data View
- Select the correct Survey Data Source
- Select the one question field
- Insert Selected Fields - New Item Form
- Highlight both columns together, right click, Modify - Merge Cells
- Delete the Cancel button and double click on the Save button
- Change the Value/Label to “Vote”
- Save Demo page and view in browser
- From the Demo page, export the Polling Web Part to your desktop
- Import the Polling Web Part and add to your page.
- Done!





So, now we have consolidated our survey into a small compact DVWP. So let’s create a voting button.


Now, if you want to take it a step further and add the Graphical Summary responses, you can do that too. I used Christophe Humbert’s Cross List jQuery script to expose the SharePoint survey summary.aspx on the same page as my poll web part. This way every time some takes the poll the page refreshes and displays the real-time poll results. Please refer to Christophe’s instructions in the links provided.

http://blog.pathtosharepoint.com/2009/03/23/display-a-list-in-another-site-contd/
http://www.pathtosharepoint.com/sharepoint-user-toolkit/Pages/Cross-Site-List-Snapshot.aspx
Guest Author: PatCharles Iovanella
PatCharles Iovanella works for major financial institution as the Americas SharePoint evangelist and subject matter expert delivering SharePoint business solutions to internal clients. You can contact him at [email protected].
Great Stuff, thanks.
Will the question change in the web part if we change on the survey? Our users are notoriously self-service and don’t want to rely on us to deploy a web part every time the question changes.
thanks again for this, it is a great idea.
Thanks PatCharles
This just gave me the missing pieces to make a small nice looking poll.
Now I just need to catch the ugly message you get when you can’t vote the second time. Any suggestion to make a small popup box with the massage or perhaps showing the result if you HAVE voted?
-Salva
Pat – can you please elaborate on how did you use Christopher’s JQuery script? I’ve tried using the script on the same page in a CEWP, but nothing happened.
Thank you
pat,
I am having same issue as Jephthah, do we not deploy the jquery script in a CEWP?
i used below code and it worked fine. you will need to insert the link to your graphical summary for your survey into the code.
Great post! Just what I was looking for… BUT I cannot get the graphical summary on the same page as the poll. I have read Christophe’s page and think I did everything he said, but did not succeed. Tried also the code Dinh provided above, but the code seems to be missing some tags :(. I use SP2007 MOSS. Can someone please paste the code for the CEWP so I can copy and paste? It’s much appreciated!
Thank you!! All I could find were coding intensive or expensive solutions. Since the survey data is in a list, I kept looking, thinking there must be a better way to do this – and found your solution. I’ll go try it out right away. Thanks for sharing this!!
Hi all,
I can get to the stage where i add the DVWP to the page in Designer but i can’t add my individual question – it just appears as a blank set of ‘id’ ‘modified by’ fields (3 fields in all) and not the question I expected to see.
All I want is to be able to export this web part into my code solution anyway, so if anyone had a working code example that would be much appreciated!
Many thanks,
HC
Hi,
Nice article, it’s just worth mentioning though trial and error that if the question doesn’t have “Require a response for this question” marked as “Yes”, the question itself will not appear in SharePoint Designer when adding the field (step 3e).
Great feedback PT!
I’d also really like to know how i can make the web part disappear once the user has taken the question, otherwise it stays there and when they try and take it again it throws a big ugly exception!
Alternatively if we could make it show the graphical results instead of the poll question that would be the real win
Hi HC,
I am also getting the same problem,If you found any solution for the same please mail me ASAP.
Thanks
This is great. However, how does one go about changing the text of the questions, once the survey web part has been added to a page?. If you modify the original survey list on the demo pages, the answer choices will update on the web part page, however the question text gets auto generated while using SPD. Just looking for a way to allow the user to change the question text and have it automatically update in the web part without having to rebuild everything. Thanks!
great post!!
what chages are required to publish this webpart in another site (in the same site collection, of course) ?
thanks
Hi Pat,
I read your article for Create a Polling Web Part with SharePoint Designer and the DVWP,I have tried doing the same but I can’t get to the stage where i add the DVWP to the page in Designer but i can’t add my individual question – it just appears as a blank set of ‘id’ ‘modified by’ fields (3 fields in all) and not the question I expected to see.
Please do let us know how to solve this.
Thanks in advance for your input!
Hii,
Ur idea is excellent. This webpart is working f9 but on voting the count of responses is not increasing. The autorefresh interval is set to 15 sec. still it is not showing…
I’m not sure what I’m missing. I was able to get the survey section to work, but I can’t get the graphical summary to show. I added a CEWP and posted the code below into the source editor. Am I missing anything?
I’d also really like to know how i can make the web part disappear once the user has taken the question, otherwise it stays there and when they try and take it again it throws a big ugly exception!
how to solve this problem