You need to sign in to do that
Don't have an account?

how to get record id using button click in visualforce page
I have a VF page which contains record id, name of account object and a button for each and every record as shown in image.
If i click the button for particular record, the respected record id should be displayed in same visualforce page. For that i created a class and VF page as given below.
VF Page:
<apex:page controller="one" action="{!save}"> <apex:form > <apex:pageBlock id="one"> <apex:pageBlockTable value="{!accs}" var="a"> <apex:column value="{!a.id}"/> <apex:column value="{!a.name}"/> <apex:column > <apex:commandButton value="click" action="{!save}" reRender="one"/> <apex:param assignTo="{!accid}" value="{!a.id}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> ID:{!accid} </apex:form> </apex:page>Controller:
public class one{ public string acName{set;get;} public integer acPhone{set;get;} public List<Account> accs{set;get;} public ID accid {set;get;} public pagereference save(){ accs = [select id,name,phone,type from account limit 5]; return null; } }I am unable to get this requirement. Could anyone please help me in this????
Thanking you
KS Kumaar
Thanks everyone. Finally i got my answer with someone help. Here is my updated code.
No need any changes on ControllerThanks
KS Kumaar
All Answers
Use wrapper class http://salesforce-walker.blogspot.com/2013/12/row-edit-and-save-using-wrapper-class.html
Hi PiotrSobczak,
Where you were totally using indexes. Never used record id.
thanks for your help. Your help is appreciable.
Use this code for query in ur controller class it will work.
Thanks,
Nitin Sharma
Thanks everyone. Finally i got my answer with someone help. Here is my updated code.
No need any changes on ControllerThanks
KS Kumaar