Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im new to slaesforce,can some point what is going wrong here.

public class listapex {
public list<selectoption> std {get;set;}
public string val{get;set;}
public listapex(){
        std= new list<selectoption>();
        selectoption s1= new selectoption('Null','--None--');
        selectoption s2= new selectoption('one','jan');
        std.add(s1);
        std.add(s2);
        std.add(new selectoption('two','feb'));
        std.add(new selectoption('three','mar'));
        }         
 public pagereference void findlabel()
 {
      for (selectoption s1 : std)
      {
               if (s1.getvalue() == val)
               {
                  val=s1.getlabel();
               }
       }
 }
}
share|improve this question
    
Updated method as below public pagereference findlabel() { for (selectoption s1 : std) { if (s1.getvalue() == val) { val=s1.getlabel(); } } return null; } ..still facing issue with error-Error Error: Unknown function findlabel. Check spelling Error Error: Unknown function findlabel. Check spelling. – Yusuf Syed Mar 15 at 10:41
    
Yusuf -- still getting error ? – Ratan Mar 15 at 11:05
    
yes..i have removes pagereference and tried..no luck still – Yusuf Syed Mar 15 at 11:11
    
Yusuf-- if you removed pagereference then you should be using void correct ? – Ratan Mar 15 at 11:13
3  
You should raise this as a new question because the initial problem was that you had an invalid class declaration, and this is a new problem. This time the problem is on your visualforce page. Hint - in action, do not use the brackets () after method name. But raise this as a new question if you are still having problems with your VF page. – Doug B Mar 15 at 11:43

This is not a valid method declaration

public pagereference void findlabel() {

You should declare the return type as EITHER void or PageReference

e.g. if the function will return a pagereference, use

public pagereference findlabel() {

or if it will return nothing use:

public void findlabel() {
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.