You need to sign in to do that
Don't have an account?
sandeep reddy 37
how to insert field and also count after insert the value counting pageblock want dissable
how to insert field and also count after insert the value counting pageblock want dissable below is the apex
++++++++++++++++++++++++++
public class counting {
public string apname{set;get;}
public string company{set;get;}
public integer view{set;get;}
public AggregateResult res{set;get;}
public list<account>acc{set;get;}
public counting(){
acc=new list<account>();
}
public void counting (){
account a=new account();
a.name=apname;
a.industry=company;
acc.add(a);
insert acc;
acc.clear();
res=[select count(name)allnames from account];
view=(integer)res.get('allnames');
}
}
and below is vf page
==================
<apex:page controller="counting" >
<apex:form>
<apex:pageblock title="counting" id="no">
<apex:pageBlockSection>
name : <apex:inputText value="{!apname}" /><br/>
industry : <apex:inputText value="{!company}"/>
</apex:pageBlockSection>
</apex:pageblock >
<apex:commandButton value="view" action="{!counting}" />
<apex:pageblock title="view" id="a">
total views is: <apex:outputText value="{!view}" />
</apex:pageblock>
</apex:form>
</apex:page>
if know please give me answer
++++++++++++++++++++++++++
public class counting {
public string apname{set;get;}
public string company{set;get;}
public integer view{set;get;}
public AggregateResult res{set;get;}
public list<account>acc{set;get;}
public counting(){
acc=new list<account>();
}
public void counting (){
account a=new account();
a.name=apname;
a.industry=company;
acc.add(a);
insert acc;
acc.clear();
res=[select count(name)allnames from account];
view=(integer)res.get('allnames');
}
}
and below is vf page
==================
<apex:page controller="counting" >
<apex:form>
<apex:pageblock title="counting" id="no">
<apex:pageBlockSection>
name : <apex:inputText value="{!apname}" /><br/>
industry : <apex:inputText value="{!company}"/>
</apex:pageBlockSection>
</apex:pageblock >
<apex:commandButton value="view" action="{!counting}" />
<apex:pageblock title="view" id="a">
total views is: <apex:outputText value="{!view}" />
</apex:pageblock>
</apex:form>
</apex:page>
if know please give me answer
Anil kumar Gorantala
to my understanding use counter property and increment it soon after inserting every account