Visualforce code:
<apex:page controller="OnlineAdmission">
<apex:form>
<style>
tr.dr1 {
background-color: #CCFF66;
color: blue;
font-size: 20px
}
tr.dr3 {
background-color: Yellow;
color: blue;
font-size: 20px
}
tr.dr1:hover {
background-color: #00FFFF;
}
tr.dr3:hover {
background-color: #FF3397;
}
</style>
<apex:pageBlock>
<table class="List" border="0" cellpadding="5" cellspacing="1">
<tr class="dr3">
<th>Welcome to Devry University</th>
<th>Main Branch office</th>
</tr>
<tr class="dr1">
<td>Candidate Name:</td>
<td>
<apex:inputtext value="{!A.Candidate_Name__c}" />
</td>
</tr>
<tr class="dr1">
<td>Online Courses:</td>
<td>
<apex:selectlist value="{!A.Online_Courses__c}" />
</td>
</tr>
<apex:pageBlockButtons>
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Save&New" action="{!savenew}" />
</apex:pageBlockButtons>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Code:
public class OnlineAdmission {
public Obj_A__c A{set;get;}
public list<Obj_A__c> B {set;get;}
public OnlineAdmission() {
A=new Obj_A__c();
B=[select id,Online_Courses__c from Obj_A__c ];
}
public pagereference save() {
insert A;
pagereference pg=new pagereference('/'+A.id);
return pg;
}
public void savenew() {
insert A; A.clear();
}
}
<apex:inputField value="{!A.Online_Courses__c}" />
should work. – Keith C Dec 14 '14 at 14:11