function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nbhradionbhradio 

searching for a custom object using custom Visual Force page

So I am building a Custom Visualforce page in which I have created a custom object say Student. Now I want to search Students using a search box in a visualforce page so that if I click on a student's name it details gets filled shown in the fields below. 

Although I tried doing it with Lookup field which I set up as Mentor for each student but I want the lookup to show student names instead of the mentors
<apex:page standardController="Student__c"   showHeader="false" >
    
 <h1 style="align: center; font-size:x-large">Student Details</h1>
 
 

<apex:form>
        <apex:inputField value="{!Student__c.Mentor__c}"/>
</apex:form>
    <apex:pageBlock>
        <apex:pageBlockSection>
            <h3>Student Name:</h3>
            <h5>Student Class: </h5> 

        </apex:pageBlockSection>
    </apex:pageBlock>


</apex:page>
Best Answer chosen by nbhradio
shaik murthujavalishaik murthujavali
Hi,
Try it using controller.
public class community1 {
    public list<contact> conlist {get;set;}
    public string value {get;set;}
    public void searchdata(){
        conlist = [select id,name from contact where name like :value];
    }
}

<apex:page Controller="community1"   showHeader="false" >
 <h1 style="align: center; font-size:x-large">Student Details</h1>
<apex:form>
    <apex:pageBlock>
        <apex:inputText label="contact name" value="{!value}"/>
    <apex:commandButton value="search" action="{!searchdata}" reRender="pb"/>
        <apex:pageBlockSection id="pb">
            <apex:pageBlockTable value="{!conlist}" var="c">
                <apex:column value="{!c.id}"/>
                <apex:column value="{!c.name}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Hope it helps.
Let me know if it helps or if need any further help.

Thanks,
Shaik Murthujavali