You need to sign in to do that
Don't have an account?
Harshal Katole 7
dynamic searching value
getting error :
Error is in expression '{!fetchData}' in component <apex:commandButton> in page searchcoursevf: Class.SearchCourse.fetchData: line 8, column 1
An unexpected error has occurred. Your development organization has been notified.
public class SearchCourse {
public string SearchText {set;get;}
public string query {set;get;}
public List<Training_Deal__c> traindeal {set;get;}
public void fetchData(){
string query = 'SELECT id, Name, Course__c,Discount__c,Student__c,Email_of_Student__c,Trainer_Appointed__c FROM Training_Deal__c WHERE Course__c =\''+SearchText+'\' ';
traindeal=Database.query(query);
system.debug(traindeal);
}
}
==============================
<apex:page controller="SearchCourse" >
<apex:form id="fm">
<apex:inputText value="{!SearchText}"/>
<apex:commandButton value="Search" action="{!fetchData}" reRender="fm"/><br/><br/>
<apex:dataTable value="{!traindeal}" var="a" cellpadding="5" rules="Rows" width="20" border="frame">
<apex:column value="{!a.Name}" headerValue="Deal code"/>
<apex:column value="{!a.Course__c}" headerValue="Course"/>
<apex:column value="{!a.Discount__c}" headerValue="Discount"/>
<apex:column value="{!a.Student__c}" headerValue="Student"/>
<apex:column value="{!a.Email_of_Student__c}" headerValue="Student Email"/>
<apex:column value="{!a.Trainer_Appointed__c}" headerValue="Trainer"/>
</apex:dataTable>
</apex:form>
</apex:page>
Error is in expression '{!fetchData}' in component <apex:commandButton> in page searchcoursevf: Class.SearchCourse.fetchData: line 8, column 1
An unexpected error has occurred. Your development organization has been notified.
public class SearchCourse {
public string SearchText {set;get;}
public string query {set;get;}
public List<Training_Deal__c> traindeal {set;get;}
public void fetchData(){
string query = 'SELECT id, Name, Course__c,Discount__c,Student__c,Email_of_Student__c,Trainer_Appointed__c FROM Training_Deal__c WHERE Course__c =\''+SearchText+'\' ';
traindeal=Database.query(query);
system.debug(traindeal);
}
}
==============================
<apex:page controller="SearchCourse" >
<apex:form id="fm">
<apex:inputText value="{!SearchText}"/>
<apex:commandButton value="Search" action="{!fetchData}" reRender="fm"/><br/><br/>
<apex:dataTable value="{!traindeal}" var="a" cellpadding="5" rules="Rows" width="20" border="frame">
<apex:column value="{!a.Name}" headerValue="Deal code"/>
<apex:column value="{!a.Course__c}" headerValue="Course"/>
<apex:column value="{!a.Discount__c}" headerValue="Discount"/>
<apex:column value="{!a.Student__c}" headerValue="Student"/>
<apex:column value="{!a.Email_of_Student__c}" headerValue="Student Email"/>
<apex:column value="{!a.Trainer_Appointed__c}" headerValue="Trainer"/>
</apex:dataTable>
</apex:form>
</apex:page>
Hi,
You can take references from the below code.
If your queries are solved please mark it as the Best Answer.
Thank You
In my org code is working fine. you can take referance from below code.
maybe there is something wrong in your query so take referance from my code.
let me know if it helps you and marking it as best answer.
Thank you