I've got this problem....
I need to make custom page for displaying survey results.....
There is one thing that I dont know how to access.....
That's the number of user answers (hits) for particular answer

eg. - If I have question that has answers

I cant get the number of how many times users respond with, lets say, Yes.

number of all user answers i get from SPList.ItemCount

Code Block
SPList survey;

Re: SharePoint - Development and Programming Display custom survey results

Lars Haupt-Hansen


You have (at least) two options:

Option 1 (foreach)

Code Block

SPList survey = ...

int yesAnswers = 0;
foreach (SPListItem item in survey.Items)

string answer = (string)item["Question1"];
if (answer.Equals("Yes"))

Option 2 (SPQuery)

Code Block

SPList survey = ...
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='Question1'/><Value Type='Text'>Yes</Value></Eq></Where>";
SPListItemCollection yesses = survey.GetItems(query);
int yesAnswers = yesses.Count;

Now option 2 performs better (source), so I'd choose that one .


Re: SharePoint - Development and Programming Display custom survey results


I have created a survey in MOSS 2007 having following questions.

1. Name

2. Email

3. Select One (having radio button options)

4. Select One from dropdownlist (having drop down list options)

5. Select (having checkbox options)

Now when I navigate to Overview page of survey, and select graphical responses.

Then the issue is - suppose 100 persons have responded to this survey then, for name and email it is showing 100 lines

which creates a very long page.

So I want to remove first two question from the Survey Graphical View responses.

In short I want to display graphical view of responses of only choice field questions. Is it possible by modifying default survey webpart

I create survey with first two compulsory questions, so I do not want to have this questions in Survey Graphical View responses page.

Please advice how can I achieve this.

Thanks in advance for your help.