title: Render Visualforcepage based on picklistValues
body: <p>I am trying to render a visualforce Page with the change in picklist values. The data I would like to render is the contact names in  a table. which changes depending on the sales Region i choose. </p>
  
  <p>Controller </p>
  
  <pre class="lang-apex prettyprint-override"><code>public class PhotoSchedulerController {
  
      public String salesRegionId { get; set; }
      public String ContactSalesRegion {get; set;}
  
      public PageReference salesRegionCoveredFilter() {
          String contacts =  [Select Id, Name, Sales_Regions_Covered__c from Contact where Sales_Regions_Covered__c = '03'].Sales_Regions_Covered__c;
          system.debug('sales region:' + contacts);
  
          return null;
      }
  
      public  List&lt;SelectOption&gt; getSalesRegionsCoveredValues() {
          List&lt;SelectOption&gt; options = new List&lt;SelectOption&gt;();
          Schema.DescribeFieldResult salesRegion = Contact.Sales_Regions_Covered__c.getDescribe();
          List&lt;Schema.PicklistEntry&gt; salesRegions = salesRegion.getPicklistValues();
          for (Schema.Picklistentry entry : salesRegions) {
              options.add(new SelectOption(entry.getLabel(), entry.getValue()));
          }
          return options;
      }
  
      public List&lt;String&gt; getHeadDays() {
          List&lt;String&gt; formattedDays = new List&lt;String&gt;();
          List&lt;DateTime&gt; days = new List&lt;DateTime&gt;();
          DateTime currentDay = DateTime.now();
          for (Integer idx = 0; idx &lt; 28; idx++) {
              days.add(currentDay + idx);
              system.debug('DAYS :' + days);
          }
          for (DateTime dt : days) {
              String formattedDay = dt.format('E');
              formattedDays.add(formattedDay);
          }
          return formattedDays;
      }
  
      public List&lt;String&gt; getHeadDates() {
          List&lt;String&gt; formattedDates = new List&lt;String&gt;();
          List&lt;Date&gt; dates = new List&lt;Date&gt;();
          Date currentDate = system.today();
          for (Integer idx = 0; idx &lt; 28; idx++) {
              dates.add(currentDate + idx);
          }
  
          for (Date dt : dates) {
              String formattedDate = dt.format();
              formattedDates.add(formattedDate);
  
          }
          return formattedDates;
      }
  
      // retrieves the row wrapper containing the wrapped case headings
      public List&lt;photographerRow&gt; getDataRows() {
          List&lt;String&gt; scheduledDates = new List&lt;String&gt;();
          photographerRow pRow = new photographerRow();
          List&lt;photographerRow&gt; dataRows = new List&lt;photographerRow&gt;();
          for (Contact con : getContacts()) {
              pRow.photographer = con.Name;
              pRow.photographerId = con.Id;
              pRow.contacts.add(con);
          }
          for (Integer idx = 28; idx &gt; 0; idx--) {
              pRow.subtotals.add(idx);
          }
  
          for (Case c : getCaseInfo()) {
              pRow.caseNumber = c.caseNumber;
              pRow.cases.add(c);
          }
  
          dataRows.add(pRow);
          return dataRows;
      }
  
      public class photographerRow {
          public String photographer {get; set;}
          public String photographerId {get; set;}
          public String caseNumber {get; set;}
          public List&lt;Contact&gt; contacts {get; set;}
          public List&lt;Case&gt; cases {get; set;}
          public List&lt;Integer&gt; subtotals {get; set;}
          public List&lt;Integer&gt; counts {get; set;}
          // constructor
          public PhotographerRow() {
              contacts = new List&lt;Contact&gt;();
              subtotals = new List&lt;Integer&gt;();
              counts = new List&lt;Integer&gt;();
              cases = new List &lt;Case&gt;();
          }
      }
  
  
      public List&lt;Contact&gt; getContacts() {
          List&lt;Contact&gt;contacts =  [Select Id, Name, Sales_Regions_Covered__c from Contact ];
          return contacts;
      }
  
  
  
      public List&lt;Case&gt; getCaseInfo() {
          List&lt;String&gt; contactsList = new List&lt;String&gt;();
          List&lt;String&gt; formattedDatesList = new List&lt;String&gt;();
          for (Contact c :  getContacts()) {
              contactsList.add(c.Name);
          }
          List&lt;Date&gt; dates = new List&lt;Date&gt;();
          Date currentDate = system.today();
          for (Integer idx = 0; idx &lt; 28; idx++) {
              dates.add(currentDate + idx);
          }
          system.debug('Dates List :' + dates);
          system.debug('Contact LIst :' + contactsList);
  
          List&lt;Case&gt; cases = [Select id, CaseNumber, Scheduled_Date__c , Account.Owner.Name, Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography')
                              and Scheduled_Date__c = :dates];
          system.debug('case queried:' + cases);
          return cases;
      }
  
  
  
      /* public Integer getCaseCount(){
          Integer caseCount;
          List&lt;AggregateResult&gt; groupedCases = [Select count(casenumber),Scheduled_Date__c, Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography') and Scheduled_Date__c!=null group by Photographer_Contact__r.Name,Scheduled_Date__c];
          for (AggregateResult ar : groupedCases)  {
                  caseCount = Integer.valueOf(ar.get('expr0'));
          }
      return caseCount;
      }*/
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;apex:page controller="PhotoSchedulerController" tabstyle="Report" sidebar="false"&gt;
      &lt;apex:form&gt;
          &lt;apex:outputPanel id="dataBlocks"&gt;
              &lt;apex:sectionHeader title="Field Researcher Schedule for Region" /&gt;
  
              &lt;apex:selectList value="{!contactSalesRegion}" size="1" multiselect="false"&gt;
                  &lt;b&gt;Field Researcher Schedule for Region&lt;/b&gt;
                  &lt;apex:selectOptions value="         {!SalesRegionsCoveredValues}"&gt;&lt;/apex:selectOptions&gt;
                  &lt;apex:actionSupport event="onchange" action="{!salesRegionCoveredFilter}" reRender="dataBlock"&gt;
                      &lt;apex:param name="salesRegionId" assignTo="{!salesRegionId}" value="{!SalesRegionsCoveredValues}"&gt;&lt;/apex:param&gt;
                  &lt;/apex:actionSupport&gt;
              &lt;/apex:selectList&gt;
  
              &lt;apex:pageBlock&gt;
  
                  &lt;table class="list" border="0" cellpadding="0" cellspacing="0" id="dataBlock"&gt;
  
                      &lt;tr&gt;
                          &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
  
                          &lt;b&gt;Scheduled Date&lt;/b&gt;
  
                      &lt;/tr&gt;
                      &lt;tr&gt;
  
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;apex:repeat value="{!headDays}" var="days"&gt;
                              &lt;th style="background-color:#00BFFF;"&gt;
                                  {!days}
                              &lt;/th&gt;
                          &lt;/apex:repeat&gt;
                      &lt;/tr&gt;
  
                      &lt;tr class="headerRow  "&gt;
                          &lt;th style="background-color:#00BFFF;"&gt;Photographer: Full Name&lt;/th&gt;
  
                          &lt;apex:repeat value="{!headDates}" var="heading"&gt;
                              &lt;th style="background-color:#00BFFF;" class="headerRow "&gt;
                                  {!heading}
                              &lt;/th&gt;
                          &lt;/apex:repeat&gt;
                      &lt;/tr&gt;
                      &lt;apex:repeat value="{!DataRows}" var="dRow"&gt;
                          &lt;apex:repeat value="{!dRow.contacts}" var="photo"&gt;
                              &lt;tr&gt;
                                  &lt;td style="background-color:#d4dadc;"&gt;
                                      &lt;a href="https://apartments--pre.cs20.my.salesforce.com/{!photo.Id}"&gt; {!photo.Name} &lt;/a&gt;
                                  &lt;/td&gt;
  
                                  &lt;apex:repeat value="{!dRow.cases}" var="count"&gt;
  
                                      &lt;td&gt;
                                          {!count.casenumber}
                                      &lt;/td&gt;
  
                                  &lt;/apex:repeat&gt;
  
                              &lt;/tr&gt;
                          &lt;/apex:repeat&gt;
  
                      &lt;/apex:repeat&gt;
                  &lt;/table&gt;
              &lt;/apex:pageBlock&gt;
          &lt;/apex:outputPanel&gt;
      &lt;/apex:form&gt;
  &lt;/apex:page&gt;
  </code></pre>
  
  <p>Thanks</p>