Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Possible Duplicate:
Add more than 1000 picklist values in visualforce page (controller 1000 list items limit)

i want to render apex:selectlist in visualforce page.with around 2000 options. but it is giving me this error .what's the solution for this error.

share|improve this question

marked as duplicate by eyescream, Samuel De Rycke, Peter Knolle, Peter, Mike Chale Jan 29 '13 at 12:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

You can only list maximum 1000 elements in visual force pages components.
You can use a paginator to show 1000 elements max per page.

public static Integer ROWS_PER_PAGE = 1000;
public Integer pageNum {get; set;}
public Boolean pageHasMore {get; set;}
public List<SomeObject> list {get; set;}
public List<SomeObject> paginatedList {get; set;}
public Integer pageNum {get; set;}
public Boolean pageHasMore {get; set;}  
public Integer firstIndex {get; set;}

public contructor(){
     pageNum = 1;
     list = YOUR_LIST_WITH_DATA;
}

public void paginateList(){
    paginatedList = new List<SomeObject>();
    firstIndex = tableRowsPerPage * pageNum - ROWS_PER_PAGE ;
    pageHasMore = pageNum < getTotalPages();
    for(Integer i=firstIndex; i<firstIndex+ROWS_PER_PAGE && list.size() > i; i++){
       paginatedList.add(list .get(i));
}
}

public void nextPage(){
    pageNum++;
    paginateList();
}

public void previousPage(){
    pageNum--;
    paginateList();
}

public Integer getTotalPages(){
   if(System.Math.mod(list.size(), ROWS_PER_PAGE ) == 0)
      return list.size() / ROWS_PER_PAGE ;
   else
      return (list.size() / ROWS_PER_PAGE ) + 1;
}

Hope this helps ;)

share|improve this answer
    
Thanks Ivo Rocha.But i dont need pagination. –  Pankaj Jan 29 '13 at 12:02

Here is a nice solution, check it out: Work Around to Overcome Collection Size Limit of 1000 elements.

share|improve this answer

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