Scenario
I’m seeing this question “Is there way to create SharePoint Survey questions programmatically ?” many times in SharePoint Forums and News Groups
Solution
The answer is that it’s definitely achievable programmatically through SharePoint API’s. The following snippet would help.
SPWeb web = SPControl.GetContextWeb(HttpContext.Current);
Guid surveyId = web.Lists.Add(“Name of the Title”, “Description of the survey”, SPListTemplateType.Survey);
SPList survey = web.Lists[“Survey List Name or Id];
string Question = “Question#1 for survey”;
StringCollection choices = new StringCollection();
choices.Add(“first choice”);
choices.Add(“second choice”);
choices.Add(“third choice”);
survey.Fields.Add(Question, SPFieldType.Choice, true, false, choices);
Pingback: Programmatically Create SharePoint Survey questions - My experiments with SharePoint, Azure and .NET using Visual Studio
IS there anyway that how to get suestions those were created in sharepoint survey.
Is there any way creating survey question using SharePoint Client OM?
It is a very good article. Now I’m trying to put a page separator to separate my questions in the survey but i’m having some problems with that. Can someone give some help on that?
Thx
yes you can programmatically find the whether the survey has questions or not. Each survey question is internally stored as content type.
I think by default a survey list would have 42 fields in the field-collection(without any question). If the field collection has more than 42 items, then obviously it has questions attached to it
Can we determine if survey list contains any question or not?
Hi,
Your article was very useful to me but I finally opted for the AddFieldAsXml as my case needed further settings.
http://sharepointologic.blogspot.com/2008/12/add-rating-scale-question-to-survey.html
I have a webpart that already build list survey type, now ,i like to know how to answer those questions , but in the same way, i mean programmatically. The problem is that i build the webpart via render, and the controls for the answer too.
So, how answer the questions dinamically in run time.