SurveyFieldIterator Class
Renders all fields in the list schema.
System.Object
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.ListFieldIterator
Microsoft.SharePoint.WebControls.SurveyFieldIterator
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.ListFieldIterator
Microsoft.SharePoint.WebControls.SurveyFieldIterator
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
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
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
- 6/3/2010
- Adam Buenz - MVP