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
siva kumar 201siva kumar 201 

How to rendered on sections in repeat attribute

I generated multiple pageblocksections based on user input and placed one custom delete button in each section. When I clicked on delete button (say in section 2) the values in section 1 are dissappeared. Can anyone help me to fix this issue

Thanks,
siva
NagendraNagendra (Salesforce Developers) 
Hi Siva,

Please check with the below sample code for account object in which i have taken four fields from account object and displayed two fields each in separate page block.First-page block has phone, website fields and second-page block has fax, billing street fields.If i click on delete button on first-page block then phone, website fields info will be deleted.

Visual Force Page:
<apex:page controller="DeletingFieldValues" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                 <apex:outputField value="{!Acc.Phone}"/>
                 <apex:outputField value="{!Acc.Website}"/>
                 
                <apex:commandButton value="Delete" action="{!OnpageLoad}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        
         <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputField value="{!Acc.Fax}"/>
                <apex:outputField value="{!Acc.Billingstreet }"/>
                
                <apex:commandButton value="Delete" action="{!OnpageLoad1}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        
    </apex:form>
</apex:page>

Apex Controller:
public class DeletingFieldValues {
    public account Acc{get;Set;}
    
    public DeletingFieldValues(){
        Acc = [Select id, Name, Phone,Fax,Website,Billingstreet from Account where ID = '001280000152Vb0'];
    }
    public PageReference OnpageLoad1() {
        Acc.Fax= '';
        Acc.BillingStreet='';
        update Acc;
        return null;
    }
    public PageReference OnpageLoad() {
        Acc.Phone= '';
        Acc.Website='';
        update Acc;
        return null;
    }
    
}
When using DML statement you can delete a particular record but if you want to empty particular field data then you can update respective fields as given in the above code.

Regards,
Nagendra.