Reputation: 229
I'm trying to filter my DataView DataSet using RowFilter.
I would like to perform a like statement on an Integer column
So something like this:
myDataView.RowFilter ="ID LIKE %1%";
This works fine for string columns but I receive an error when trying this will integers. I receive the follow error: Cannot perform 'Like' operation on System.Int32 and System.Int32.
Anyway of doing a LIKE statement on numbers?
Thanks in advance.
Upvotes: 3
Views: 7299
Reputation: 223
This gets the specific item requested. It works on one item exactly
"Convert(DataGridColumnName, 'System.String') LIKE '%" & txtBox.Text & "%' "
Example 1:
DV.RowFilter = "Convert( TicketNo , 'System.String') LIKE '%" + txtTicketNo.Text + "%'
This only receive the exact ticket number if you want to retreive items like that start with it receives all items that start with
Example 2:
DV.RowFilter = "Convert( TicketNo , 'System.String') LIKE '" + txtTicketNo.Text + "%' ";
In Theory the first Example should be looking in the whole string and searching for matches. The one that I have done does not do that maybe I had missed something,
Upvotes: 0
Reputation: 49
It worked with me:
"Convert(DataGridColumnName, 'System.String') LIKE '%" & txtBox.Text & "%' "
Upvotes: 4