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

Argument 1 cannot be null An unexpected error has occurred. Your development organization has been notified.
i written this in appex class
public class Soql_Example3 {
public List<Account> accounts {set;get;}
public List<selectoption> options {set;get;}
public Soql_Example3(){
accounts = [select id,Name,phone from account];
options = new List<selectoption>();
selectoption n = new selectoption('none','-None-');
options.add(n);
for(account a:accounts){
selectoption op = new selectoption (a.Phone,a.name);
options.add(op);
}
}
}
i written this in visual force
<apex:page controller="Soql_Example3" >
<apex:form>
<apex:selectList size="1">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
</apex:form>
</apex:page>
when i execute this program iots getting error message
Error-
Argument 1 cannot be null
An unexpected error has occurred. Your development organization has been notified.
public class Soql_Example3 {
public List<Account> accounts {set;get;}
public List<selectoption> options {set;get;}
public Soql_Example3(){
accounts = [select id,Name,phone from account];
options = new List<selectoption>();
selectoption n = new selectoption('none','-None-');
options.add(n);
for(account a:accounts){
selectoption op = new selectoption (a.Phone,a.name);
options.add(op);
}
}
}
i written this in visual force
<apex:page controller="Soql_Example3" >
<apex:form>
<apex:selectList size="1">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
</apex:form>
</apex:page>
when i execute this program iots getting error message
Error-
Argument 1 cannot be null
An unexpected error has occurred. Your development organization has been notified.
Greetings to you!
You should make sure you don't have any null elements. The real problem lies in these lines:
If the a.Phone or a.name field is NULL, options is added with NULL.
So change those lines as below:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
You should make sure you don't have any null elements. The real problem lies in these lines:
If the a.Phone or a.name field is NULL, options is added with NULL.
So change those lines as below:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
its working .