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

pick list
hello group,
i have 2 obj enquiry and course i developed 2 pages for both enquiry and course . In enquiry page i want to have picklist field 'select course',
but iam not able to execute perfectly.........
pls go through my below code and resolve my prblm
<apex:outputLabel style="font-weight:Bold" value="Select a course :" />
<apex:SelectList size="1" value="{!lst}">
<apex:selectOptions value="{!items}"/>
</apex:SelectList>
----------------------------------------------------------------------------------------------
public List<Course__c> lst{get;set;}
public Course__C getlst() {
if (lst == null) {
lst = [select Name from Course__c];
}
return lst;
}
}
public List<SelectOption> getItems(){
List<SelectOption> options = new List<SelectOption>();
for(Integer i=0; i < lst.size(); i++){
options.add(new SelectOption(lst[i].Name,lst[i].Name));
}
return options;
}
iam getting an error that 'un expected token ' at line 'public List<SelectOption> getItems(){'
note: i dont have a field picklist in my enquiry obj... but i wanrt to display it in vf page is this possible to do
pls help me ............
thanks for giving reply in advance
hello group i got over the above error
iam getting new one' Return value must be of type: SOBJECT:Course__c' at line return lst;
Ravi,
That because you have declared return type as Course__c instead of List<Course__c>.
thanks for giving reply srinu
but iam facing 'System.NullPointerException: Attempt to de-reference a null object
Class.Enquiry.getItems: line 70, column 1' at line for(Integer i=0; i < lst.size(); i++)
thanks & regards
ravi
Ravi,
You can try something like this. Also I suspect your Course__c is not having data, double check that.
You could save some lines of code and grief by doing this:
thanks for giving reply thematty