You need to sign in to do that
Don't have an account?
dev rana 10
I m trying to insert value from vf page to sobject but value will not pass from text box.
Hi all i m new in salesforce i m trying to insert value in sobject but value of inputfiled is not passing in sobject.
this is my Controller
public class reg {
devrana__registration__c registration = new devrana__registration__c();
public devrana__registration__c getregistration()
{
return registration;
}
public PageReference save()
{
insert registration;
return null;
}
}
this is my Vf page
<apex:page controller="reg" >
<apex:form >
<p><b>registraion Page</b><br /></p>
<apex:panelGrid columns="2" style="margin-top:1em;">
<p><b>UserName</b><br />
<!--apex:inputText required="true" id="username" /-->
<apex:inputField value="{!registration.name__c}"/>
</p>
<p><b>Password</b><br />
<apex:inputSecret id="password" />
</p>
<apex:commandButton action="{!save}" value="Register" id="register" immediate="true"/>
</apex:panelGrid>
</apex:form>
</apex:page>
this is my record which is Auto number
this is my Controller
public class reg {
devrana__registration__c registration = new devrana__registration__c();
public devrana__registration__c getregistration()
{
return registration;
}
public PageReference save()
{
insert registration;
return null;
}
}
this is my Vf page
<apex:page controller="reg" >
<apex:form >
<p><b>registraion Page</b><br /></p>
<apex:panelGrid columns="2" style="margin-top:1em;">
<p><b>UserName</b><br />
<!--apex:inputText required="true" id="username" /-->
<apex:inputField value="{!registration.name__c}"/>
</p>
<p><b>Password</b><br />
<apex:inputSecret id="password" />
</p>
<apex:commandButton action="{!save}" value="Register" id="register" immediate="true"/>
</apex:panelGrid>
</apex:form>
</apex:page>
this is my record which is Auto number
VF:
This is a basic working example.
You can modify it to suit your requirement.
If this asnwer helps you out, mark it as BEST ANSWER.
All Answers
VF:
This is a basic working example.
You can modify it to suit your requirement.
If this asnwer helps you out, mark it as BEST ANSWER.
i change a code as per your help when i m trying to insert it gives me this error.
Visualforce Error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page devrana:reg: Class.devrana.re.save: line 4, column 1
Class.devrana.re.save: line 4, column 1
now it not insert in sobject. still its not working.
its done. just change my fild name in vf page and its working thanks u so much for your help.