Monday, July 3, 2017

How To Display Drop down Values With Check Box in Visual Force Page

If you want to display each drop down value with the checkbox you can use the below code snippet.In below code we are using Salesforce tag called <apex:selectCheckboxes> and inside that we are adding all the SelectOptions.

Source Code:

In VisualForce Page:

<apex:selectcheckBoxes value="{!selFruits}" >
 <apex:selectOption itemLabel="Mango" itemValue="Mango" />
 <apex:selectOption itemLabel="Apple" itemValue="Apple" />
 <apex:selectOption itemLabel="Banana" itemValue="Banana" />
 <apex:selectOption itemLabel="Guava" itemValue="Guava"/>
        <apex:selectOption itemLabel="Orange" itemValue="Orange"/>

</apex:selectcheckBoxes>

In Apex Class:

Public List<String> selFruits{get;set;} // This should be list not Single String


OutPut:



Thanks for visiting..hope this helps you!

No comments: