+ Start a Discussion
Simha YadavSimha Yadav 

i want to change row of color in visualforce page.

Please Help anybody.... i want to change row of color in visualforce page when the Email Status column shows Email has sent then it should change that row color to light green if it shows as not sent then it should change the color to red,How do i do this?
But i did something but its not working below is my code.

<apex:page standardController="Account" extensions="WrapperDemoClass" showHeader="false" sidebar="false">
  <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                    inputCheckBox[i].checked = obj.checked;
    .EmailnotSentClass {
        background-color: #F7DDDD;
    .EmailSentClass {
        background-color: #66FF99;

  <apex:form >
    <apex:pageBlock title=" Account Invoice">
    <apex:pageMessages />
     <apex:commandButton value="Send Email" action="{!sendEmail}" reRender="pgBlckId" status="actStatusId" />
       <apex:actionStatus id="actStatusId" >
       <apex:facet name="start" >
       <apex:image url="{!$Resource.Image}" />
       <apex:pageblockTable value="{!wrapperObj}" var="Rec" title="All Accounts">
         <apex:column styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}">      
         <apex:facet name="header">
         <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
         <apex:inputCheckbox value="{!Rec.checkBox}" id="inputId" />
         <apex:column value="{!Rec.accObj.name}" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}"/>
         <apex:column value="{!Rec.accObj.phone}" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}"/>
         <apex:column value="{!Rec.accObj.Email__c}" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}"/>
         <apex:column headerValue="Created Date" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}">
             <apex:outputText value="{0,date,dd/MM/yyyy}">
                 <apex:param value="{!Rec.accObj.createddate}"/>
         <apex:column value="{!Rec.accObj.Type}" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}"/>
         <apex:column value="{!Rec.accObj.Email_Status__c }" id="pgBlckId" styleClass="{!IF(colorcheck == 'green','EmailnotSentClass','EmailSentClass')}"/>

public with sharing class WrapperDemoClass {
    Public List<WrapperClassEx> WrapperList{get;set;}
    public List<Account> accList {get;set;}
    public boolean checked {get;set;}
    public string  colorcheck {get;set;}
    public WrapperDemoClass(ApexPages.StandardController controller) {
       colorcheck = '';
   Public List<WrapperClassEx> getwrapperObj(){
      accList = [Select id,name,phone,Email__c,createddate,type,Email_Status__c from account];
      WrapperList = New List<WrapperClassEx>();
      for(Account acc: accList){
        WrapperList.add(New WrapperClassEx(acc,false)); 
      return WrapperList;
   public void sendEmail(){
       checked = false;
     List<Messaging.SingleEmailMessage> lstEmailId=new List<Messaging.SingleEmailMessage>();
         PageReference pdf = Page.newreq;
        // add parent id to the parameters for standardcontroller
        // the contents of the attachment from the pdf
        Blob body;
        try {
          // returns the output of the page as a PDF
          body = pdf.getContent();
        // need to pass unit test -- current bug  
        } catch (VisualforceException e) {
          body = Blob.valueOf('Some Text');
     for(WrapperClassEx w : WrapperList){
        for(Account a : accList){
            if(w.accObj.id == a.id){
                system.debug('w.checkBox :'+w.checkBox);
                if(w.checkBox == true){
                    /*if(w.accObj.Email__c == null){
                        w.ErrorMessage = 'Email has not sent! Please check with your Admin.';
                    Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
                    attach.Body = body;
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    mail.setToAddresses(new String[] {w.accObj.Email__c});
                    mail.setSenderDisplayName('Your Company Name');      
                    mail.setSubject('Test Email From Force.com Sites');  
                    mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });      
                        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  
                        checked = true;
                        a.Email_Status__c  = 'Email has sent!';
                        colorcheck = 'green';
                    }catch(exception e){ 
                        a.Email_Status__c  = 'Email has not sent! Please check with your Admin.';
                        colorcheck = 'red';
                    system.debug('lstEmailId :'+lstEmailId);                        
      upsert accList;

   Public Class WrapperClassEx{
     Public Account accObj{get;set;}
     Public Boolean checkBox{get;set;}
     public String ErrorMessage{get;set;}
     Public WrapperClassEx(Account accRec, boolean SelectBox){
        accObj = accRec;
        checkBox = SelectBox;
Gyanender SinghGyanender Singh
Hi simha,

Can you send the image of the Statice Resource Image because want to implement this code and try to solve your problem.