This control renders each field in a list item with an appropriate control. A single line text field will be rendered as a text box while a lookup field will be rendered as combo box. This control resides in the Microsoft.SharePoint.WebControlsnamespace of the Microsoft.SharePoint.dll.
You can use this control in a custom application page or in a custom Edit, New and Display form.
In its simplest way you can declare the control as follows:
<sharepoint:ListFieldIterator ID="TestListFieldIterator" runat="server" ControlMode="New" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" />
This renders the first list item as follows:
You can set different properties of the ListFieldIterator control:
- ListId: This property must contain the id – which is a Guid - of the list you want to display.
- ControlMode: Defines whether the controls are displayed in display mode, edit mode or new mode.
- ExcludeFields: Specify the fields that don’t need to be rendered. Separate each field with ;#
- Item: In code behind, you can retrieve the current list item by using this property.
- ItemId: in code behind, you can retrieve the id of the current list item. But you can also decide which item to render by setting this attribute declaratively.
<sharepoint:ListFieldIterator ID="TestListFieldIterator" runat="server"
ControlMode="Edit" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" ItemId="2" />
- List: In code behind, you can retrieve the current list by using this property.
- Template: you can set this property if you have deployed your own custom template to the 12\TEMPLATE\CONTROLTEMPLATES folder.
Comments
Post a Comment