You need to sign in to do that
Don't have an account?
venkyyy
if there is no data in a field the page has to show error as no data found in vf page,
Hi all,
Please have a look on bellow code, and i have to show error message that if there is no data.
-----------------page-----------
<apex:page controller="controllerError">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lst}" var="con" rendered="{ !IF(lst.size() == 0,True,False)}">
<apex:column value="{!con.TestField__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:outputText rendered="{ !IF(lst.size()== 0,True,False)}" value="There are no contacts to display." />
</apex:pageBlock>
</apex:page>
----------------controller-------
public with sharing class controllerError {
public list<Contact> lst{ get; set;}
public controllerError(){
lst = [select name,TestField__c from contact];
}
}
-----------
suggest me what i need to add.
Please have a look on bellow code, and i have to show error message that if there is no data.
-----------------page-----------
<apex:page controller="controllerError">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lst}" var="con" rendered="{ !IF(lst.size() == 0,True,False)}">
<apex:column value="{!con.TestField__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:outputText rendered="{ !IF(lst.size()== 0,True,False)}" value="There are no contacts to display." />
</apex:pageBlock>
</apex:page>
----------------controller-------
public with sharing class controllerError {
public list<Contact> lst{ get; set;}
public controllerError(){
lst = [select name,TestField__c from contact];
}
}
-----------
suggest me what i need to add.
Try the update visualforce page code
Thanks,
Karanraj (http://www.karanrajs.com)
I did the same what you said and doing paste bellow, it is not working as per my expectaion, can u check it once and do correct me where i did wrong,
-----------vf----
<apex:page controller="controllerError">
<apex:pageMessage summary="No Contacts" severity="error" rendered="{!IF(lst.size == 0,True,False)}" strength="1" > </apex:pageMessage>
<apex:pageBlock rendered="{!IF(lst.size != 0,True,False)}">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lst}" var="con" >
<apex:column value="{!con.TestField__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
--------controller---
public with sharing class controllerError {
public list<Contact> lst{ get; set;}
public controllerError(){
lst = [select name,TestField__c from contact];
}
}
----
Thanks,
Venky.