+ Start a Discussion
harsha__charsha__c 

Binding a variable between VF page and controller

Here is my Requirement

 

I given 'h' in the search field in VF page.

When i press the search button it should display the all Account Names starting with 'h' letter

 

In handler I have a variable of string type and is binded to the VF page.

Now my doubt is,

      How to get the AccountNames starting with the letter stored in the string variable.....

 

 

Can  anyone  suggest me the way

Best Answer chosen by Admin (Salesforce Developers) 
harsha__charsha__c

I got the Answer

 

 

i.e.

 

select Name from Account where Name like : str ;

All Answers

Abhay AroraAbhay Arora

Hi Hasha,

 

You can just make a SOQL query with like %%  syntax

harsha__charsha__c

Let me be more clear

 

where i know that

 

                  select Name from Account where name like 's%' limit 10;

 

    will work

 

But in my case, String str='s';

 

          Now Can i run the same query by using the  str instead of the regular pattern

harsha__charsha__c

I got the Answer

 

 

i.e.

 

select Name from Account where Name like : str ;

This was selected as the best answer
sf@sfsf@sf

Thanks, Harsha Vardhan. This helped me too.