function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vamshi(Nani)vamshi(Nani) 

Select Options problem

<apex:page controller="Selectpick">
<apex:form >
<apex:selectlist value="{!sv}">
<apex:selectOptions value="{!options}"/>
</apex:selectlist>
</apex:form>
</apex:page>

 

 

-----------------------APEX CLASS------------------------------

public class Selectpick
{

public List<selectoption> getOptions()
{
List<selectoption> option= new List<selectoption>();
option.add(new SelectOption('1','Value 1'));

return option;
}


public String sv { get; set; }
}

 

 

 

 

 

I got this error:

Error: Selectpick Compile Error: Constructor not defined: [Selectoption].<Constructor>(String, String) at line 7 column 20

 

 

 

Abhi_TripathiAbhi_Tripathi

hI,

 

Your code is just working fine, But i have changed something, take a look and try. you were not initiallizing you string that you defined

 

public class Selectpick {

    public List<selectoption> getOptions() {

        List<selectoption> option= new List<selectoption>();
        option.add(new SelectOption('1','Value 1'));

        return option;
    }

    public String sv { get; set; }
    
    //Constructor
    public Selectpick() {
    
        SV = '';
    }
}

 

vamshi(Nani)vamshi(Nani)
Hi,

Thank you for your mail; my code is still not working..instead of solution I got new errors...

Error Error: Selectpick Compile Error: Invalid constructor name: Selectpic at line 14 column 11


you defining constructot..but it should have return type..

2)for sv value I have given getter and setter it will hold that value..

please check in your account once...and help me in this thanks in advance.