Programmatically Create SharePoint Survey questions
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);
Subscribe to my post