You need to sign in to do that
Don't have an account?
vagish
selectlist help
hi,
public List<SelectOption> getItems() {
List<SelectOption> op=new List<SelectOption>();
for(List<Student__c>student:[select name from Student__c])
{
op.add(new SelectOption(student.name));
}
return null;
}
In this code, I want to add student names into selectOption, but it is giving error:
Error: nameController Compile Error: Initial term of field expression must be a concrete SObject: LIST<Student__c> at line 7 column 33.
Thanks in advance!!
Please try this one
public List<SelectOption> getItems() {
List<SelectOption> op=new List<SelectOption>();
for(List<Student__c> student : [select name from Student__c])
{
op.add(new SelectOption(student.name, student.name));
}
if(op.size() > 0)
return op;
return null;
}
If still you are facing issues... please post complete controller's code.
hi problem get resolved by changing the for loop line like this:
for(Student__c student:[select id,name from Student__c])