I don't know any other way to include something like ToString()
method in a Expression
string for RowFilter
but this way it works:
lbxTracks.DataSource = new DataView(das.Tables[0], "TrackID + '' LIKE '" + idNo + "'", "TrackName", DataViewRowState.CurrentRows);
NOTE the + ''
this will turn your TrackID
into string
before performing the LIKE
. And it works like a charm. If anyone knows another way to perform some ToString()
on a column in the RowFilter
string, please leave comment below. I'm really appreciated for that :)
You should use string.Format()
to concatenate string, and notice about the use of %
in LIKE
expression. I think in this case you may want to use the right operator (=
is OK for number) if you just want to compare the equality in value (not format).