ForEach Element (View)
Provides a basic mechanism for enumerating a collection of views or fields defined in the current list.
The value of the Select attribute varies in the different schema files:
CHOICES/CHOICE inside a Choice field. Note capitalization and the lack of a leading forward slash (/). In this case, the ForEach element must be nested inside another ForEach element that enumerates Fields/Field (in other words, inside a Fields element). The current point in the Fields enumeration must be a Choice field.
/FIELDS/Field for enumerating all the fields in the current list.
/FORMS/Form for enumerating all the forms for a particular list (very similar to views).
/LISTTEMPLATES/ListTemplate for enumerating all the server-supported list definitions specified in the Onet.xml file (for announcements, tasks, contacts, events, and so on).
/DOCUMENTTEMPLATES/DocumentTemplate for enumerating all the server-supported document library template files (Microsoft Excel worksheet, Microsoft Word document, etc.).
The body of the ForEach element is rendered once for each view or field in the collection. The Property element can be used to extract individual properties of the view or field.
The ForEach element can also be used to reference a single field or view. To do so, a variable must be set with the name of the desired field or view; the MatchVar attribute is used to reference that variable.
The following example uses the ForEach element to construct a drop-down list box.