How to store value checked by checkbox ( on the VF page ) in the database with controller?

Sample Code:

Visualforce page:

<apex:page controller="Sample">
<apex:form >
    <apex:pageblock >
        <apex:pageBlockSection >
            <apex:panelGrid columns="2">
                Name :
                <apex:inputText value="{!Nam}"/>
                Skilled :
                <apex:inputCheckbox value="{!Skilled}"/>
        <apex:commandButton value="Save" action="{!sav}"/>

Apex Controller:

public class Sample { 
    public String Nam {get;set;}
    public Boolean Skilled {get;set;}
    Integer n = 5;
    public List<Member__c> MemList {get;set;}
    public Sample() {
    public void sav() {
        Member__c Mem = new Member__c();
        Mem.Name = Nam;
        Mem.Skilled__c = Skilled;
        insert Mem;

1 comment:

  1. Well, that is actually very knowledgeable and the most reliable thing to be known about the database with controller. Thanks for sharing this benevolent post.


Sharing is Caring!!! Share this with your friends!!!

submit to reddit