How to use Like in free text search on Datadview.Rowfilter or DataTable.Select()

  • Thread starter Thread starter Jensen bredal
  • Start date Start date
J

Jensen bredal

Hello,

I need to implement a free text search on an asp.net page.
I need to search two columns based on a text entered in a tex box.

it should be possible to search any subsrting included in one of the two
columns.


I did the following:


DataView dv=MyOriginaleDataTable .DefaultView;

dv.RowFilter=" column1 Like ' "+srearchstring.text +" ' or column2 Like '
"+ srearchstring.text+ " ' ";


......
MydataList.DataSource =dv.

..........

This is not working.

Can someone tel me what i'm doing wrong?

Many thanks
JB
 
.... Like '%"+srearchstring.text +"%' ...

What you have written will only find it if the column contains the exact
string plus an explicit leading apsace and an explicit trailing space.

The power of 'Like' is provided by it's wildcard characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top