function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mdinatalemdinatale 

Newbie saving data in a datatable

I have saved data before but not from a datatable, basically what i want to do is save each row of data as a new record in my object. Not sure how to do this. It displays the data exactly how i want it just need to save it. I really need some direction any help would be appreciated.

 

<apex:page standardController="Zones_List__c" extensions="RAPI"  showHeader="false" sidebar="false" standardStylesheets="false">
  Zones
  
  
  <apex:outputPanel id="databox" >                   
    <apex:outputPanel id="dataPanel">     
       <apex:outputText value="{!DisplayZones}"  escape="false"/>
    </apex:outputPanel>
  </apex:outputPanel>
  
   <apex:form >
         
         <apex:commandButton id="ZoneUpdate" action="{!ZUpdateList}"  value="Update Zones" />
         <apex:inputText id="account_num" value="{!Zones_List__c.Account__c}"/>         
        <apex:pageBlock title="Zones" id="tblId">
          <apex:dataTable value="{!ZS}" var="r" cellPadding="4" border="1">
           <apex:column >
            <apex:facet name="header">Zone</apex:facet>
            <apex:outputText value="{!r}" />
            <!--<apex:inputText id="rZone" value="{!Zones_List__c.Rapid_Zone_Name__c}"/> -->
           </apex:column>
           <apex:column >
             <apex:facet name="header">Equipment</apex:facet>
              <apex:selectList size="1" id="equip" value="{!Zones_List__c.Equipment_Points__c}">
                <apex:selectOptions value="{!Equip}"/>
              </apex:selectList>            
           </apex:column>
           
           <apex:column >
             <apex:facet name="header">Location</apex:facet>
              <apex:selectList size="1" id="location" value="{!Zones_List__c.Location__c}">
                <apex:selectOptions value="{!ZLoc}"/>
              </apex:selectList>
            
           </apex:column>
           
          </apex:dataTable>          
         </apex:pageBlock>
         
     </apex:form>

</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
Damien_Damien_

in your controller all you need is:

 

upsert zs;