I have a wrapper class list which include check box values and sobject values like :

            SKUs_for_Car_Sales__c=Luc Zero Orange,
            Date_of_SKU_Purchase__c=2017-02-14 00:00:00

How can I obtain CarSales_Boot__c's object details in order to bind it to a pageblock's table?

This is the apex method I am using:

public void removeProducts() {
    Integer selectedCount2 = 0;

    List<Integer> toDelete = new List<Integer>();

    for(integer i = 0; i < wrpList.size(); i++){

            //first add it to the list to delete:
        } else {

    // remove it from your list.
    for(Integer x : toDelete){

Providing your wrapper exposes the SObject using a property e.g.:

public class YourWrapper {
    public CarSales_Boot__c csb {get; set;}

you can reference it like this in a Visualforce table:

<apex:pageBlockTable value="{!wrpList}" var ="w">
    <apex:column value="{!w.csb.Name}"/>
    <apex:column value="{!w.csb.CreatedDate}"/>


Related to the comment on how to insert the SObjects, you just need to add the references to the new list (no need to modify the wrpList):

CarSales_Boot__c[] csbs = new CarSales_Boot__c[] {};
for (YourWrapper w : wrpList) {
insert csbs;
  • @kiran If this answer addressed your problem, please consider accepting it by clicking on the check mark/tick to the left of the answer, turning it green. This marks the question as resolved to your satisfaction, and awards reputation both to you and the person who answered. If you have >= 15 reputation points, you may also upvote the answer if you wish. There is no obligation to do either. – Adrian Larson Feb 14 '17 at 14:47
  • I would tend to prefer to name the property record here, personally. – Adrian Larson Feb 14 '17 at 20:24
  • @Keith C,here I can able to show details in pageblock table ,but inorder to insert sobject details into the DB we have to extract from the wrapper class right,here i am facing the issue. – kiran Feb 15 '17 at 5:06
  • actually I am getting wrapper list ,and at the end I have to insert object list into sobject by extracting it from wrapper list...plz suggest better way...wrpList.remove(x); //from this wrplist I have extract sobject details. – kiran Feb 15 '17 at 8:50
  • @kiran See the PS in the answer. – Keith C Feb 15 '17 at 10:20

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.