function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mobile vistexmobile vistex 

map key not found

hi iam trying to get data from map when i display on visualforce page it is giving error map key not found . but in my it is present . my apex code is 
<apex:page controller="test" sidebar="false" showHeader="false">
<apex:pageBlock >


<table>
<apex:repeat value="{!data}" var="j">

<tr>


<td>{!j['AgrName']}</td>
<td>{!j['driver']}</td>

<td> {!j['temvar']}</td>

<td>{!j['tem']}</td>


</tr>
<apex:outputText value="{!j}"></apex:outputText>
</apex:repeat>


</table>

</apex:pageBlock>
</apex:page>

and my controller is like following 
public class test{
Integer k = 20;
public String  temvar{get;set;}
public String  tem{get;set;}

list<map<String,String>> temp = new list<map<String,String>>();
public test(){
  temvar = '';
  tem = ' ';

}


public list<map<String,String>> getdata(){
for(list<Agreement1__c> k: [select name,driver__c,period__c,sales__C,quantity__c from Agreement1__c order by period__c])
{
for(Integer i =0;i < k.size();i++){
map<String,String> temp1 = new map<String,String>();


 Integer flag = 1;
          
          for(map<String,String> temp3: temp){ 
          
          
                   if(temp3.get('AgrName') == k[i].name){       
                   flag = 0;
               }
          }
          if(flag  == 1){
            temp1.put('AgrName',k[i].name);            
          }
          else{
            temp1.put('AgrName','');  
          }
          temvar=k[i].period__c + '_S';
          tem =k[i].period__c + '_Q' ;
          
          temp1.put('driver',k[i].driver__c);
          temp1.put('temvar',k[i].sales__c);  
          temp1.put('tem',String.valueOf(k[i].quantity__c));   
           
          
temp.add(temp1);
}

}
return temp;
}

}

please tell me how can i display that quantity field in visual force page
Nitin PaliwalNitin Paliwal
Hi,
Please try this code. Let me know if there is any issue.
<apex:page controller="test" sidebar="false" showHeader="false">
<apex:pageBlock >


<table>
<apex:repeat value="{!data}" var="j">
 <tr>
 <Apex:repeat value="{!j}" var="mapKey">
  


  <td>{!j[mapKey]}</td>
  <td>{!j[mapKey]}</td>

  <td> {!j[mapKey]}</td>

  <td>{!j[mapKey]}</td>


  
 </apex:repeat>
 </tr>
 <apex:outputText value="{!j}"></apex:outputText>
</apex:repeat>


</table>

</apex:pageBlock>
</apex:page>

Thanks
Nitin