+ Start a Discussion

How to edit records by selecting checkboxes?


I have been given an assignment. Which is as per follow:-

Create a VF page 
This page contains list of contacts.
By default these records are not editable.
Each record has a checkbox.
If user clicks on a checkbox, then corresponding record will become editable.
User can modify that reocrd
Like that user can select multiple records and can modify them.
After changes, save all only those records which are editable.
After saving the records refresh page and display updated record.
All checkboxes now should become unchecked.

I have create a VFpage and a controller for that but i unable to get desire output.Vf page code is as shown
<apex:page controller="BulkUpdateController">
<apex:form >
   <apex:actionFunction name="selectCheckBox" action="{!selectCheckBox}" rendered="block">
   <apex:param name="a" value="" assignTo="{!selectedCheckBox}"/>
    <apex:pageBlock >
            <th>First Name</th>
            <th>Last Name</th>
        <apex:repeat value="{!RecordList}" var="rec">
            <td><apex:inputText value="{!rec.FirstName__c}" disabled="true"/></td>
            <td><apex:inputText value="{!rec.LastName__c}" disabled="true"/></td>
            <td><apex:inputText value="{!rec.Email__c}" disabled="true"/></td>
            <td><apex:inputCheckbox value="{!rec.CheckIn__c}" onclick="select()"/></td>
        <apex:pageBlockButtons >
          <apex:commandButton value="Save" action="{!SaveMe}"/>
          <apex:commandButton value="Cancel" action="{!Cancel}"/>     
       function select(){

code for controller is

public class BulkUpdateController{
    public List<Student__c> RecordList{get;set;}
    public Boolean selectedCheckBox{get;set;}
       public BulkUpdateController(){
       RecordList = new List<Student__c>();
       RecordList = [SELECT FirstName__c, LastName__c, Email__c, checkIn__c FROM student__c];
      public PageReference SaveMe(){
        upsert RecordList;
        // PageReference pg = new PageReference('/' + student.id);
        return null;
     public PageReference Cancel(){
     pagereference pg = new pagereference('https://ap1.salesforce.com/home/home.jsp');
    return pg;
    public PageReference selectCheckBox(){
    RecordList = new List<Student__c>();
    RecordList = [SELECT FirstName__c, LastName__c, Email__c, checkIn__c FROM student__c WHERE checkIn__c =: selectedCheckBox];
    return null;
This is the code for page and controller.Am i coding in right way.please Help me if somebody can.