You need to sign in to do that
Don't have an account?

Applying styles
Display opportunities in the pageblock table.
If stage name is closedwon,display that row in red,
if stagename is closedlost,display that row in green,
if stagename is others,display that row in yellow.
Hi,
Use the below code snippet as reference:
---------- Vf page----------------
<apex:page controller="myOppsController" tabStyle="Opportunity">
<apex:form >
<apex:sectionHeader title="Opps List" />
<apex:pageBlock title="" id="pageBlock">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!opportunities}" var="o" rendered="{!NOT(ISNULL(opportunities))}">
<apex:column style="{!IF(o.StageName=='Closed Lost','background:lightgreen',IF(o.StageName=='Closed Won','background:red','background:yellow'))}" >{!o.StageName}</apex:column>
<apex:column style="{!IF(o.StageName=='Closed Lost','background:lightgreen',IF(o.StageName=='Closed Won','background:red','background:yellow'))}" >{!o.Name}</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
-------- apex controller ---------------
public class myOppsController
{
private List<Opportunity> opportunities;
public List<Opportunity> getOpportunities()
{
opportunities = [Select Name, Amount, Account.Name, CloseDate,StageName from Opportunity];
return opportunities;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.