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

Insert data in object on click of button
Please can anybody tell me that how to send data to object after clicking on button of the visualforce page...
Just guide me whether setter & getter property are required by the controller class & then it is transffered to the object by DML query....Not getting my self clearly so please guide me quickly..
Please reply me urgently & I am w8ting...
you have the standard controller with you in that page..?
Hi Bhola Vishwakarma,
This is very simple...
For example:
Just add this in the save function
database.saveresult binsert = database.insert(b,false);
Before doing this you should create instance for the object.
In the above line of code b is object instance
Hi,
As per my uderstanding related to your posting how to insert data in object onclick of button can be achieved by 2 ways.
1)by using custom controller and VF pages
2)using ajax
public with sharing class accountinsert {
public String no { get; set; }
public String names { get; set; }
public PageReference save() {
Account a=new Account(Name=names,AccountNumber=no);
insert a;
return null;
}
}
<apex:page controller="accountinsert">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
Name:<apex:inputText value="{!names}"/>
Account Number:<apex:inputText value="{!no}"/>
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Hiii ....Dskvap
As you told, I understood that how it will get insert record but the fact which i am not getting is that what is binsert & of which object b is instance....
Can u elaborate your things fully...
Your help is appreciate the most...
Regards...
Hi Bhola Vishwakarma,
please find the solution
yes getter setter property is required
Apex class
VF
If you find this solution is helpful for you please mark best answer