free text search . Newbie question.

  • 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 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
 
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!)
 
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
 
Back
Top