Reply
Contributor
sandysf11
Posts: 5
0

how to retrieve current page records into a pageblock table when a add button clicks

in my page, we have enter values in fields and click the command button 'add', then tat record added to a pageblocktable and displays in the same page as a row of that table without saving in the database.can anyone suggest me to achieve this scenario.

 

Immediate reply will appreciable.

Thanks in advance...

 

 

 

 

 

 

Super Contributor
Navatar_DbSup
Posts: 2,085
0

Re: how to retrieve current page records into a pageblock table when a add button clicks

Hi,

Try below code snippet as reference:

 

------------------- Vf page-----------------

 

<apex:page controller="cls_wrapperexample" >

  <apex:form >

      Name : <apex:inputtext value="{!name}"/><br/>

       Email : <apex:inputtext value="{!email}"/><br/>

        Phone : <apex:inputtext value="{!phoneno}"/><br/>

        <apex:commandButton reRender="pgtable" action="{!addnewrow}" value="Add New Row"/>

  <apex:pageBlock >

      <apex:pageBlockTable value="{!listaddrow}" id="pgtable" var="tt">

          <apex:column ><apex:facet name="header">Name</apex:facet> {!tt.name1}</apex:column>

           <apex:column ><apex:facet name="header">Email</apex:facet>{!tt.email1}</apex:column>

            <apex:column ><apex:facet name="header">Phone No</apex:facet>{!tt.phoneno1}</apex:column>

      </apex:pageBlockTable>

 

  </apex:pageBlock>

  </apex:form>

</apex:page>

 

------------------------- Apex Controller -----------------------------

 

public class cls_wrapperexample

{

public string name{get;set;}

public string email{get;set;}

public string phoneno{get;set;}

public list<addrow> listaddrow{get;set;}

public cls_wrapperexample ()

{

    listaddrow=new list<addrow>();

}

public void addnewrow()

{

    addrow temp=new addrow();

    temp.name1=name;

    temp.email1=email;

    temp.phoneno1=phoneno;

    listaddrow.add(temp);

}

 

public class addrow

{

    public string name1{get;set;}

public string email1{get;set;}

public string phoneno1{get;set;}

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

Ankit
Navatar Group
Contributor
sandysf11
Posts: 5
0

Re: how to retrieve current page records into a pageblock table when a add button clicks

its show an error...

invalid field for the object.