[SalesForce] Display List values using Visualforce page

Can anyone please help me how to display the list values using a VF page.
Below is my controller comparison logic:

for(obj__c Type : subType)
{
    for(obj__c gen : generalList)
    {
        if(Type.Sub_Type__c == gen.Sub_Type__c)
        {
            genValue = gen.sub_Type__c;
            System.debug ('genValue -----------'+genValue);
        }
    }
}

genValue is a string which stores the list of sub_Type field values. now I wanted to display all the list values for every iteration of for loop using a vf page. I tried displaying as :
value="{!genValue}"
but as it is a string the page is displaying only one value.
Can anyone please help me display all the list values as long as the outer for loop iterates
Thanks in advance.

Best Answer

You should be able to use the <apex:repeat> tag to display your list values. From the help docs here, here is an example:

For this example to render properly, you must associate the Visualforce page

with a valid account record in the URL.

For example, if 001D000000IRt53 is the account ID, the resulting URL should be:

https://Salesforce_instance/apex/myPage?id=001D000000IRt53

See the Visualforce Developer's Guide Quick Start Tutorial for more information.

<!-- Page: -->

<apex:page standardController="Account">

    <table border="0" >

        <tr>

            <th>Case Number</th><th>Origin</th>

            <th>Creator Email</th><th>Status</th>

        </tr>

        <apex:repeat var="cases" value="{!Account.Cases}">

        <tr>

            <td>{!cases.CaseNumber}</td>

            <td>{!cases.Origin}</td>

            <td>{!cases.Contact.email}</td>

            <td>{!cases.Status}</td>

        </tr>

        </apex:repeat> 

    </table>

</apex:page>

Update: Try swapping out the variables in the above example with your list and values. Something like this should work:

<!-- Page: -->

<apex:page standardController="Your standard or custom object here">

    <table border="0" >

        <tr>

            <th>Sub Type</th>

        </tr>

        <apex:repeat var="ten" value="{!generalList}">

        <tr>

            <td>{!gen.Sub_Type__c}</td>

        </tr>

        </apex:repeat> 

    </table>

</apex:page>
Related Topic