You need to sign in to do that
Don't have an account?
sreelekha
To display the values of record from pageblock table to inputText fields in the same page
Hi,
I have created a vf page with two pageblocks .
One "pageBlock" contains "inputText" fields with Save Button.Other Contains a pageBlock table with "Edit" link in each row.
Here when i click on "Save" button then it is saved to database and automatically updated in the below "PageBlock Table" in the same page.
Now i have the requirement,
when i click on "Edit" link on the particular row of the "PageBlockTable" then automatically the values of each cell of table set to respected "inPutText" fields in the above "PageBlock".
can any one reply me please?
can you please share your code, so that we can help you in this problem
//Here is the code i wrote
public class TestController1
{
public PageReference getAccount() {
return null;
}
//TestController t=new TestController();
public String sname{get;set;}
public Double inumber{get;set;}
public String scountry{get;set;}
public String sid{get;set;}
public PageReference recSave()
{
Departments__c dep= new Departments__c(id=sid,Name=sname,No_of_Employees__c=inumber,Countries__c=scountry);
insert dep;
//system.debug('------------>'+sid);
return null;
}
List<Departments__c> a;
public List<Departments__c> geta()
{
a=[select name,id,No_of_Employees__c,Countries__c from Departments__c];
//system.debug('departmentrecords'+a);
return a;
}
}
---------------------------Page----------------------------------------------------------------------------
<apex:page controller="TestController1" id="pg">
<apex:form id="f1">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!recSave}" value="save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:outputLabel >Name :</apex:outputLabel>
<apex:inputText value="{!sname}" required="true"/>
<apex:outputLabel >No_Of_Employees :</apex:outputLabel>
<apex:inputText value="{!inumber}" required="true"/>
<apex:outputLabel >Country:</apex:outputLabel>
<apex:selectList id="chooseColor" value="{!scountry}" size="1" required="true">
<apex:selectOption itemValue="none" itemlabel="--None--"></apex:selectOption>
<apex:selectOption itemValue="india" itemLabel="India"/>
<apex:selectOption itemValue="usa" itemLabel="USA"/>
<apex:selectOption itemValue="china" itemLabel="China"/>
</apex:selectList>
<apex:outputText value="{!sid}" rendered="false"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="pb">
<apex:pageBlockTable value="{!a}" var="ab" id="pt">
<apex:column value="{!ab.name}"/>
<apex:column value="{!ab.No_of_Employees__c}"/>
<apex:column value="{!ab.Countries__c}"/>
<apex:column value="{!ab.id}" id="rid"/>
<apex:column Headervalue="Action"><apex:outputLink title="" value="/{!ab.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink></apex:column>
<apex:column Headervalue="Actiion"><apex:commandButton value="Edit"/></apex:column>
<!--<apex:column><apex:outputLink value="/{!ab.id}" >Edit1</apex:outputLink></apex:column>-->
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
hi,
Few things to consider in your code
1) There is no need to take getter setter for every field. If that field is of some Custom or standard object, you can simply create a instance of that object and call that instance from VF page. for example in the following code
in that way, you can call any field exists in account object by calling it as {!account.fieldAPIname}
i have modified your code as per the account object. you can use any object by replacing account with your object name.
VF page:
Controller: