Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day

How can I use special characters % and * in DataView.RowFilter
expression in which I have already LIKE statement?


I am using a DataView to display records from datatable. I allow
users to enter the string which will be pasted into RowFilter in such way

MyDataView.RowFilter= myColumn LIKE '%"+MyTextBox.Text+"%'";


What must I change in the RowFilter Statement?
Posted

hi

dataView.RowFilter = "Name LIKE '%ad%'" // values that contain 'ad'
if you want for the value of textbox,Please try to concatenate it

dataView.RowFilter = "Name LIKE '%"+MyTextBox.Text+%'";
 
Share this answer
 
Comments
Member 13336882 29-Oct-17 0:17am    
now,suppose i have multiple columns in my db/dgvw,so how do i configure the code to search in multiple columns ? e.g. i got 3 columns named [first name],[last name],gender..
Member 13017471 12-Feb-20 4:53am    
just using "and" "or" logic syntax.

eg: dv.RowFilter = "[status] like '%Pending%' AND [alarm]='High' and [id]=" & structdoms.st_data(j).id
I wrote the following and it works

ViewTermDetails.RowFilter = string.Concat("CONVERT(", myColumn,",System.String) LIKE '%", Textbox.Text, "%'"); 
 
Share this answer
 
v2
Comments
[no name] 19-May-17 8:12am    
Good. It works for me too.
Member 15290222 15-Jul-21 6:07am    
Fantastic Solution Jaco, there are many solutions in the WEB that doesn't function, Yours it's the only good and functional !!!
Thank You very, very much !!!

C.
to
VB
Rate:

 very good
Solution 2



Great Answer

thankssssssssss
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900