title: Q>How to fix "DML currently not allowed" when accessing visualforce page
body: <p>I edited my class and saved it successfully but when I accessed my page which uses the class, I get an error of</p>
  
  <p><strong>DML currently not allowed</strong> 
  An unexpected error has occurred. Your development organization has been notified.</p>
  
  <p>here is my controller</p>
  
  <pre><code>public class DefinitionController {
  
      public DefinitionController() {
          this.DefTable();
      }
  
      public void DefTable() {
          listplatforms = [select Name, Status__c from Platform__c];
  
          for (Platform__c idlistplatforms : [select Id from Platform__c]) {
              List&lt;Def__c&gt; existplatforms = [select Platform__c from Def__c where Platform__c = :idlistplatforms.Id];
  
              if (existplatforms.size() &gt; 0) {
                  idlistplatforms.Status__c = 'Set';
                  //update idlistplatforms;
                  System.debug('Found' + idlistplatforms);
              } else {
                  idlistplatforms.Status__c = 'Not Set';
                  //update idlistplatforms;
                  System.debug('Not Found' + idlistplatforms);
              }
              update idlistplatforms;
          }
      }
  
  }
  </code></pre>
  
  <p>I think the problem is because of the <strong>update</strong> part. Can someone please edit my code so that I will overcome that error? </p>
  
  <p><strong>Thanks in advance!</strong></p>