You need to sign in to do that
Don't have an account?
sumanforce@gmail.com
How to store data
Hi Friends, I have designed a form using visualforce. After filling the form, i attached a controller (Apex Class). I need to save the data to the database. Can you please help me Thanks suman
Hi Suman,
Use the below code sample as reference
<apex:page controller="savecontact">
<apex:form>
<apex:panelgrid columns="2">
LastName:<apex:inputText value="{!lastname}" />
EmailId:<apex:inputText value="{!mailid}" />
<apex:commandbutton value="Save" Action="{!insertcontact}" />
</apex:panelgrid>
</apex:form>
</apex:page>////////////////////////// Controller /////////////////////
Public class savecontact
{
Public string lastname{get;set;}
Public string mailid{get;set;}
Public void insertcontact()
{
Contact cont=new contact (lastname=lastname, email=mailid);
Insert cont;
}
}
All Answers
You are using a custom controller so hopefully you can write a save method in your controller to save the data to the object.
Regards,
J
Hi,
Use the below code sample as reference
<apex:page controller="Test">
<apex:form >
LastName:<apex:inputText value="{!lname}" /><br/>
EmailId:<apex:inputText value="{!Conemail}" /><br/>
<apex:commandbutton value="Save" Action="{!JustSave}" />
</apex:form>
</apex:page>////////////////////////// Controller /////////////////////
Public class Test
{
Public string lname{get;set;}
Public string Conemail{get;set;}
Public void JustSave()
{
Contact con=new contact (lastname=lname, email=Conemail);
Insert con;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Suman,
Use the below code sample as reference
<apex:page controller="savecontact">
<apex:form>
<apex:panelgrid columns="2">
LastName:<apex:inputText value="{!lastname}" />
EmailId:<apex:inputText value="{!mailid}" />
<apex:commandbutton value="Save" Action="{!insertcontact}" />
</apex:panelgrid>
</apex:form>
</apex:page>////////////////////////// Controller /////////////////////
Public class savecontact
{
Public string lastname{get;set;}
Public string mailid{get;set;}
Public void insertcontact()
{
Contact cont=new contact (lastname=lastname, email=mailid);
Insert cont;
}
}
Hi Anji,
Thanks for the help.
I have executed the code..but how to see where the lastname, email are stored.
Please help
Thanks
Venkat