Rating Scale in SharePoint Survey List Programmatically

In SharePoint Survey List, Rating scale is very useful and easy to implement, set properties and use in SharePoint. It is a column type which is available only for the survey lists. If we are creating Survey lists programmatically, I found an easy way to implement this rating scale in SharePoint using Feature activation coding.

When you are Creating a survey list programmatically, add this field to the SharePoint survey list.


  //Adding Question to Survey List Programmatically with rating scale
  strQuestionTitle = "Lecturer Skills";

  StringCollection strQuestions = new StringCollection();
  strQuestions.Add("Share Knowledge");
  strQuestions.Add("Provide guidance");
  objSurvey.Fields.Add(strQuestionTitle, SPFieldType.GridChoice, true, false, strQuestions);

  //Updating Rating scale field properties
  SPFieldRatingScale srs = objSurvey.Fields[strQuestionTitle] as SPFieldRatingScale;
  srs.GridTextRangeLow = "Low";
  srs.GridTextRangeHigh = "High";
  srs.GridTextRangeAverage = "Avg";
  srs.GridStartNumber = 1;
  srs.GridEndNumber = 5;
  srs.GridNAOptionText = "NA";

  //Updating survey list

Hope this article is helpful and here ends your searching.

Sudheer Gangumolu

I'm a Software Analyst / Developer / Blogger, having good experience in working with different flavors & Customization of SharePoint (i.e.,SP O365 / 2013 / 2010 / 2007) and .Net Apps. Currently, working on SharePoint 2013 / SharePoint O365. Guiding people on my technologies.

    Blogger Comment
    Facebook Comment


Post a Comment