+ Start a Discussion
Vandana RattanVandana Rattan 

Set Default Values in PageBlockTable Input fields

I have a product Pageblock table. There are some input fields in the table and I need to set default values for these. How can I achieve this? Code is pasted below:-

<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.ServiceDate.Label}">
                        <apex:inputField value="{!s.ServiceDate}" required="false"/>
 </apex:column>

<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Quantity.Label}">
                    	<apex:inputField value="{!s.Quantity}" style="width:70px" required="true" 
                    </apex:column>


Best Answer chosen by Vandana Rattan
Hargobind_SinghHargobind_Singh
Hi Vandana, 

You can set the values for fields in constructor of your controller, if you are using a custom controller or an extension. 

Another way would be to use javascript to set initial values, but that could be tricky. Controller would be simpler. 


All Answers

Hargobind_SinghHargobind_Singh
Hi Vandana, 

You can set the values for fields in constructor of your controller, if you are using a custom controller or an extension. 

Another way would be to use javascript to set initial values, but that could be tricky. Controller would be simpler. 


This was selected as the best answer
Vandana RattanVandana Rattan
Thanks Hargobind. Got it!!!