+ Start a Discussion
Mike445Mike445 

Access Data Category from VisualForce page

Hi,

We are building a visualforce page and would be displaying articles in it. We have several product lines that corresponds to a category in the Data Category list.

 

Our goal is to have a visualforce page for every product line and in each of those pages the top category (Product Family) should be auto selected so the items are the only ones to be selected by the users.

 

I am developing a Visual Force page and want to access data category elements as a select list. 

 

 

 

I appreciate any help you can give or if you could point me to the right resource.

 

Thanks,

Mike.

Edwin VijayEdwin Vijay

Maybe, something like this?

 

<apex:selectList value="{!selectedcategory}">
            <apex:selectOptions value="{!datacategories}"/>
</apex:selectList>


Class

String selectedcategory {get;set}
            

            
        public List<SelectOption> getdatacategories() {
            List<SelectOption> options = new List<SelectOption>();
            for (DataCategory__c datacat: [Select Id,Name from DataCategory__c])
                options.add(new SelectOption(datacat.ID,datacat.Name));           
            return options;
        }
            

 

Mike445Mike445

Thanks Edwin. I shall try it. I am a beginner struggling hard to accomplish tasks. Appreciate your help.

 

Mike.