Code Snippet: Using the List Field Iterator to display a list form in a SharePoint Web Part
September 12th, 2011
You can use the list field iterator to show the ‘New’, ‘Edit’, and ‘Display’ form in a web part. The List Field Iterator will show all fields in your list view that you specify, and inherits the properties you specify for the view as well (such as column ordering and visible fields).
<%@ Register TagPrefix="spuc"
Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint,
Version=12.0.0.0,
Culture=neutral,
PublicKeyToken=71e9bce111e9429c"
%>
<tr>
<td>
<spuc:ListFieldIterator ID="TestListFieldIterator"
runat="server"
ControlMode="New"
ListId="{29e3dbfe-00c7-48a1-b242-50383f2244b2}" />
</td>
</tr>
Line 13 in this example shows the “ControlMode” as ‘New’, but you can change this to ‘Edit’ and ‘Display’, depending on what you want to do. The ‘New’ ControlMode does not require the itemID parameter.
