free text search . Newbie question.

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 some characters text entered in a text
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
 
K

Karl Seguin

It would help to be more specific than "not working" but I imagine you mean
it doesn't return substrings...

you need to use either * or % (doesn't matter which)...

column1 like %'" + searchString.Text +"'% ....

also, don't put a space between the single quote ' and the double quote "

else it'll look for " some value " notice the spaces...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
J

Jensen bredal

My error

was putting ' before %. I swithed and now it works.


Though i have an other concern.

How to get the macthing rows after the dataview.rowfilter operation?

The problem is that when the search fails there is no way the content of the
dataview appears amibgus . and causes my datalist to behave unexpetedlty.


Is this a bug?


Many thanks
JB
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top