This topic has not yet been rated - Rate this topic

SurveyFieldIterator Class

Renders all fields in the list schema.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SurveyFieldIterator : ListFieldIterator

This class provides page views for new and edit forms. It is used by surveys to break the survey forms into separate pages based on PageSeparator fields and any Branching logic.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
SurveyFieldIterator
Description

The Microsoft.SharePoint.WebControls.SurveyFieldIterator class inherits from Microsoft.SharePoint.WebControls.ListFieldIterator which will render fields from a explicit SPList object. SurveyFieldIterator takes special consideration for survey template types (corresponding to SPListTemplateType.Survey) when performing enumerations on SPList fields collection.

The principal functionality of SurveyFieldIterator is to support the survey response display where users enter appropriate answers to the related questions. SurveyFieldIterator black boxes a majority of the functionality, making it workable to set a brief amount of properties on the SurveyFieldIterator object, notably the SPList.ID of the target list and SPControlMode specifying when the iterator should display results.

It should be noted that with the use of SurveyFieldIterator it is imperative to take into post actions to harness the values entered into the control. This is generally as something like toggling a user to a results mode. This type of behavior is not handled within the control, and would require wiring a separate event. 

Usage Scenario

The primary usage of SurveyFieldIterator within custom development is rendering the survey response display contents. It is an orthodox control, therefore can simply be added to a instance control collection.

In the below, I am demonstrating creating two SharePoint proxy objects, a SPWeb which is going to use the current context and a SPList which will look for a list titled "Survey". Following, I am instantiating a new SurveyFieldIterator object and setting the minimal properties for proper control function. Lastly, the control is added to the current control collection.

C# Code Example

protected override void CreateChildControls()
{
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Survey"];
SurveyFieldIterator survey = new SurveyFieldIterator();
survey.ListId = list.ID;
survey.ControlMode = SPControlMode.New;
Controls.Add(survey);
base.CreateChildControls();
}

Visual Basic .NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
Dim web As SPWeb = SPContext.Current.Web
Dim list As SPList = web.Lists("Survey")
Dim survey As New SurveyFieldIterator()
survey.ListId = list.ID
survey.ControlMode = SPControlMode.[New]
Controls.Add(survey)
MyBase.CreateChildControls()
End Sub

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com