I'm getting below error when I'm trying to pass values from map to pageblocktable in Visualforce page.

ERROR : Incorrect parameter type for subscript. Expected Number, received Text


<apex:pageBlockTable id="thetable" title="Invoice line item" value="{!Invoiceitemsmap}" var="inv" >

                        <apex:column headerValue="Nicomatic Part No"><apex:inputtext value="{!Invoiceitemsmap[Inv].Name}" required="true" /></apex:column>  



Public Map<Integer,List<Invoice_line_item__c >> Invoiceitemsmap{get;set;}
            contactList = [Select Name,Client_Part_No__c from Invoice where Id =:"SomeId"];
            totalCount = contactList.size();
            Invoiceitemsmap=new Map<Integer,List<Invoice_line_item__c>>();

closed as unclear what you're asking by Raul, Mohith Shrivastava, glls, Reshma, battery.cord May 31 at 14:22

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Invoiceitemsmap[Inv] would give you a List<Invoice_line_item__c >, you would have to rewrite your code with use of wrapper classes to make code simpler. – Raul May 29 at 12:51
  • You mean I need to write wrapper class and pass that wrapper list to there then it will also be the same right it is also a list only – vinodkumar May 29 at 12:53

You are getting that error because, you are trying to use the dot notation on list variable on visualforce page.

As your Map structure is Map<Integer,List<Invoice_line_item__c>>,you will have to use two PageBlockTable's in order to display your Map in visualforce page, in first iteration of PageBlockTable, it will return you List<Invoice_line_item__c> and you cannot access the individual field's value i.e. Name from list without using the index. So in order to display this List again, you will have to use one more PageBlockTable.

Your visualforce page should be something like this

<apex:pageBlockTable id="thetable" title="Invoice line item" value="{!Invoiceitemsmap}" var="inv" >
    <apex:column >
        <apex:pageblocktable value="{!Invoiceitemsmap[Inv]}" var="inv1">
            <apex:column headerValue="Nicomatic Part No"><apex:inputtext value="{!inv1.Name}" required="true" /></apex:column>

Not the answer you're looking for? Browse other questions tagged or ask your own question.