You need to sign in to do that
Don't have an account?
Parteek Goyal 3
Error: Unknown constructor 'student.student()
Hi,
public class student{
public Student__c lststudent{get;set;}
public String str{get;set;}
public student(ApexPages.StandardController sc){
String studentid=sc.getID();
if(studentid == null && studentid == ''){
lststudent=[SELECT id from student__c where id=:studentid];
}
else{
lststudent=new Student__c();
}
}
public PageReference savemethod(){
insert lststudent;
if(str =='new'){
lststudent=new Student__c();
str=null;
}
return null;
}
public List<Student__c> getrecord(){
List<Student__c> allrecord=[SELECT id,name__c,manager__c,address__c,email__c from Student__c];
return allrecord;
}
}
----------------------------------------
<apex:page Controller="student">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!savemethod}"/>
<apex:commandButton value="Save and New" action="{!savemethod}"/>
<apex:param id="name" value="new" assignTo="{!str}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!lststudent.name}"/>
<apex:inputField value="{!lststudent.Name__c}"/>
<apex:inputField value="{!lststudent.Email__c}"/>
<apex:inputfield value="{!lststudent.Phone__c}"/>
<apex:inputField value="{!lststudent.Manager__c}"/>
<apex:inputField value="{!lststudent.Address__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:pageBlock title="Records">
<apex:dataTable value="{!record}" var="r">
<apex:column >
<apex:outputLabel title="hh">Name</apex:outputLabel>
{!r.Name__c}
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>
this will show an error:
Error: Unknown constructor 'student.student()
and please also tell me how to set header name of a column when we show a list record on a page.
please help me
public class student{
public Student__c lststudent{get;set;}
public String str{get;set;}
public student(ApexPages.StandardController sc){
String studentid=sc.getID();
if(studentid == null && studentid == ''){
lststudent=[SELECT id from student__c where id=:studentid];
}
else{
lststudent=new Student__c();
}
}
public PageReference savemethod(){
insert lststudent;
if(str =='new'){
lststudent=new Student__c();
str=null;
}
return null;
}
public List<Student__c> getrecord(){
List<Student__c> allrecord=[SELECT id,name__c,manager__c,address__c,email__c from Student__c];
return allrecord;
}
}
----------------------------------------
<apex:page Controller="student">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!savemethod}"/>
<apex:commandButton value="Save and New" action="{!savemethod}"/>
<apex:param id="name" value="new" assignTo="{!str}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!lststudent.name}"/>
<apex:inputField value="{!lststudent.Name__c}"/>
<apex:inputField value="{!lststudent.Email__c}"/>
<apex:inputfield value="{!lststudent.Phone__c}"/>
<apex:inputField value="{!lststudent.Manager__c}"/>
<apex:inputField value="{!lststudent.Address__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:pageBlock title="Records">
<apex:dataTable value="{!record}" var="r">
<apex:column >
<apex:outputLabel title="hh">Name</apex:outputLabel>
{!r.Name__c}
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>
this will show an error:
Error: Unknown constructor 'student.student()
and please also tell me how to set header name of a column when we show a list record on a page.
please help me
As it seems from your code your are using this page either on a detail page or on custom button to show a VF page , so simply modified first line of you vf page as shown below
Use this to remove above error
<apex:page StandardController="Student__c" extensions="student" >
Use Apex:facet to show heder for column as shown below for your case
<apex:column >
<apex:facet name="header">Name</apex:facet>
{!r.Name__c}
</apex:column>