You need to sign in to do that
Don't have an account?

How to bind the json values to the Selectlist
public class test5 { public list<string> lststatename{get;set;} public list<string> lstrating{get;set;} public list<string> lstactive{get;set;} public map<string, string> statemap{get;set;} public map<string, string> activestatusmap{get;set;} public set<string> mapkey{get;set;} public list<string> mapvalue{get;set;} public test5(){ string jsonexample1 = ' { "overalldata": [ {"stateName": "Andrapradesh", "rating": "5.0" , "active": "yes" }, { "stateName": "Telangana", "rating": "4.0" ,"active": "no" }, {"stateName": "Banglore", "rating": "5.0" ,"active": "no"} , {"stateName": "Maharastra", "rating": "4.5" ,"active": "no" } ] } '; map<string,object> metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); list<object> values1= (list<object>)metadatamap.get('overalldata'); lststatename= new list<string>(); lstrating= new list<string>(); statemap= new map<String, string>(); for(object parsed : values1){ map<string,object> values = (map<string,object>)parsed; string statename = string.valueof(values.get('stateName')); string rating= string.valueof(values.get('rating')); lststatename.add(statename); lstrating.add(rating); statemap.put(statename,rating); } } }Visual force page:
<apex:page controller="test5" > <apex:form > <apex:repeat value="{!statemap}" var="a"> <apex:selectList > <apex:selectOptions value="{!a}">{!a}</apex:selectOptions> </apex:selectList> </apex:repeat> </apex:form> </apex:page>
Hi..! can any body bind data to the selectlist with statename as itemlabel and rating as the itemvalue in visualforce page
.. Thank you..!
Use this code this will help you.
Apex Class:
VisualForce Page:
Regards,
Soyab
All Answers
We can use selecOption List instead of Map.
Use this code this will help you.
Apex Class:
VisualForce Page: If you found it useful please appreciate my efforts and mark it as the best answer.
LinkedIn: https://www.linkedin.com/in/soyab-hussain-b380b1194/
Regards,
Soyab
The code is working fine..!thank you..! onchage it was not showing the selected value and i need the rating value too. to display..
Visualforce page:
Thanks in Advance!
Deepika
Use this code this will help you.
Apex Class:
VisualForce Page:
Regards,
Soyab