i have is_active__C checkbox on account object. so my requirment is on visualforce page i want to take one check box as 'show active accounts only'.when ever its checked i want to show active accounts only(which account checked while creating account record).otherwise show all accounts

i wrote dis PAGE

       <apex:pageblockTable value="{!accountList}" var="wrapRec" rendered="{!selectedList}">
           <apex:column value="{!wrapRec.Name}" />
           <apex:column value="{!wrapRec.Id}"/>               


public class accountExtension{
    public List<Account> accountList{get;set;}
    public accountExtension(ApexPages.StandardController controller){
        accountList = [SELECT id ,Name FROM Account];
    public boolean activeAccountOnly{get;set;}
    public void showActiveAccounts(){
        accountList = new List<myWrapperClass>();
        normalList = false;
        selectedList = true;
        if(activeAccountOnly == false)
            accountList = [SELECT id ,Name FROM Account WHERE is_active__C =TRUE];
            accountList = [SELECT id ,Name FROM Account];

error illage assignmntand compie err

  • Can you provide what you have so far? From reading your description I'm sure the community would be able to help but this is a community to answer questions and help with your code if you don't provide anything its very hard for the community to answer (we're not going to write the code for you) – thegogz May 11 '15 at 12:03
  • on vf page i created one chekbok with name show active accounts and have one command button get accounts. if the chekbox is checked i want to show only active accounts – Praveen Naraharisetty May 11 '15 at 12:08
  • 1
    Welcome to SF.SE Praveen. Are you asking about a List View? If not, please post your code to show us what you've done so far or this question will be closed. If you need help learning the Salesforce Platform, I recommend the following resources Visualforce Workbook and the [Visualforce Developer’s Guide].(developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/…, Suggest you also visit the Help center and take our Tour to better understand how this forum works. – crmprogdev May 11 '15 at 13:16
  • Please provide full code, so that community helps you. I think that solution provided by Samuel is good. – Anurag Bhardwaj Mar 19 '16 at 15:07
  • Try replacing accountList = new List<myWrapperClass>(); this to accountList = new List<Account>(); – itzmukeshy7 Apr 18 '16 at 14:54

It always helps when you include on what line the error is, or mark that in your code. But, i'm going to assume it's the following:

 public List<Account> accountList{get;set;}
 accountList = new List<myWrapperClass>();

You've declared it as type List<Account>, this means you CAN NOT assign another type list to it, yet that is what you're doing. You either have to declare it differently, or assign it correctly.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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