You need to sign in to do that
Don't have an account?
Geetha B
Hai , I am getting the following error in wrapper class .
Error Error: wrapperclassinstance Compile Error: Constructor not defined: [wrapperclassinstance.testwrapperclass].<Constructor>(String, Decimal, Decimal, String, String) at line 15 column 22
here is my program
public with sharing class wrapperclassinstance
{
public wrapperclassinstance() {}
list<position__c> pos = new list<position__c>();
list<employee__c> emp = new list<employee__c>();
list<testwrapperclass> wrapcls = new list<testwrapperclass>();
public list<testwrapperclass> getlstwrapperdisplay()
{
pos = [select name,min_pay__c,max_pay__c from position__c];
emp = [select name,Passport_Number__c from employee__c];
for(integer i = 0;i<pos.size();i++)
{
wrapcls.add(new testwrapperclass(pos[i].name,pos[i].min_pay__c,pos[i].max_pay__c,emp[i].name,emp[i].passport_number__c));
}
return wrapcls;
}
public class testwrapperclass
{
public string pname{get;set;}
public integer maxsal{get;set;}
public integer minsal{get;set;}
public string ename{get;set;}
public string passportnumber{get;set;}
public testwrapperclass(string pname,integer maxsal,integer minsal,string ename,string passportnumber)
{
this.pname= pname;
this.maxsal=maxsal;
this.minsal=minsal;
this.ename=ename;
this.passportnumber = passportnumber;
}
}
}
here is my program
public with sharing class wrapperclassinstance
{
public wrapperclassinstance() {}
list<position__c> pos = new list<position__c>();
list<employee__c> emp = new list<employee__c>();
list<testwrapperclass> wrapcls = new list<testwrapperclass>();
public list<testwrapperclass> getlstwrapperdisplay()
{
pos = [select name,min_pay__c,max_pay__c from position__c];
emp = [select name,Passport_Number__c from employee__c];
for(integer i = 0;i<pos.size();i++)
{
wrapcls.add(new testwrapperclass(pos[i].name,pos[i].min_pay__c,pos[i].max_pay__c,emp[i].name,emp[i].passport_number__c));
}
return wrapcls;
}
public class testwrapperclass
{
public string pname{get;set;}
public integer maxsal{get;set;}
public integer minsal{get;set;}
public string ename{get;set;}
public string passportnumber{get;set;}
public testwrapperclass(string pname,integer maxsal,integer minsal,string ename,string passportnumber)
{
this.pname= pname;
this.maxsal=maxsal;
this.minsal=minsal;
this.ename=ename;
this.passportnumber = passportnumber;
}
}
}
In your wrapper class contain the following parameters,
Your are passing values to the above constructor like below,
So while passing data to the consturctor make sure the parameter should be same data type as what you have mentioned, For example
you can try below code for your problem,
All Answers
In your wrapper class contain the following parameters,
Your are passing values to the above constructor like below,
So while passing data to the consturctor make sure the parameter should be same data type as what you have mentioned, For example
you can try below code for your problem,