+ Start a Discussion
Rick RollRick Roll 

N>Help Auto Selecting Selectlist Value based on Co-Row Value

Hello everyone.
I have a pageblocktable with 3 rows that are dynamically produced from an object Sample__c
As you can see Column3 contains a selectlist with values from Colu1__c which is also listed on column 2 of the table
User-added image
My problem is when I load the page, the values on the picklist are all set to --Select-- but I wanted each of them to automatically choose its corresponding column 2 value (as selected)as default when I load the page.
ex. if the column 2 of the table has Very Good, its corresponding selectlist column should make Very Good as selected value

Can someone please tell me how to do this?
 
Jigar.LakhaniJigar.Lakhani

Hello,

You need to enter Status(Coul1__c) field in value attribute of <Apex:SelectList> of third column.
For more information, can you please give page and controller code?

Thanks & Cheers,
Jigar (pateljb90@gmail.com)

 

Ajay K DubediAjay K Dubedi
Hi Rick,
I think your problem can be solved by initializing the select list value in your constructor with the values which you are displaying in column2(Status).  
 Ex : 
public class test{
 
public test(){
  selectedfield = '1';
}
 
public list<selectOption>getOptions(){
list<selectOption>val=new list<selectOption>();
for(i=1;i<=5;i++){
val.add(new selectOption(String.valueOf(i),String.valueOf(i))
}
<apex:selectList size="1" value="{!selectedfield}">
<apex:selectOptions value="{!Options}"/>
</apex:selectList>
So in this example you can whic ever value is intialized in the constructor then that value will be visible in the select list.
please mark as best if it helps for you.