my picklist value comes from an object but upon page load, i want to have '--select student--' as the default value of the picklist.
controller snippet
public List<selectOption> getsNames(){
List<selectOption> options = new List<selectOption>();
options.add(new selectOption('', '--Select Student--'));
for(Parent__c p : [Select Id, Name, First_Name__c, (Select Id, First_Name__c, Name from Students__r)
from Parent__c WHERE Name = 'Delgado']){
for(Student__c stud : p.Students__r){
selectedSId = stud.Id;
options.add(new selectOption(stud.Id, stud.First_Name__c + ' ' + stud.Name));
}
}
return options;
}
in this code, the '--select student--' appears on the top but on page load, the name of the student appears. how can i make it a default that '--select student--' is the value of the picklist?
VFP
<apex:pageBlock id="chooseStudentPageBlock" >
<div>
<apex:outputLabel style="margin-left: 55px;">Select Student:</apex:outputLabel>
<apex:actionRegion>
<apex:selectList size="1" style="margin-left: 5px;" value="{!selectedSId}" >
<apex:actionSupport event="onclick" reRender="teacher"/>
<apex:selectOptions value="{!SNames}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!fetchTeacherInfo}" reRender="teacherBlock"/>
</apex:selectList>
</apex:actionRegion>
</div>
</apex:pageBlock>