VisualForce Row Count

This is my first tutorial on VisualForce – a markup language for Force.com.

The scenario was I needed to display a numbering for each child record found on the master record without coding an extension or using a controller.

My solution. Code below would loop to the child records and display each result found. The number count is declare as a variable with a value that starts at 1 before the start of the repeat tag and then another variable tag declaring using the same variable, using the formula VALUE before the end of the repeat to initialize it from text to a number integer then incrementing it by one.

<apex:variable value=”1″ var=”rowNum”/>
<apex:repeat value=”{!Work_Order__c.Work_Order_Charges__r}” var=”List” id=”theRepeat”>
<tr>
<td><apex:outputtext value=”{!rowNum}”/></td>
<td>{!List.Quantity__c}</td>
<td>{!List.Description__c}</td>
<td>{!List.Rate__c}</td>
</tr>
<apex:variable var=”rowNum” value=”{!VALUE(rowNum) + 1}”/>
</apex:repeat>