SandyB Posted November 25, 2003 Posted November 25, 2003 I'm trying to filter data in a datagrid that can have columns with string and integer datatypes. I can't figure out how to write the filter string using 'like' for the integer columns. I have: Dim sb As New System.Text.StringBuilder sb.Append(dc.DataField + " like '" + dc.FilterText + "*'") ' filter the data DsMasterDetail1.Tables(0).DefaultView.RowFilter = sb.ToString() which works fine for the string columns, but throws an exception when I enter an integer for an integer column. How can I write a filter string that says "convert the value of the integer column data to a string" so that I can filter for characters entered. Thanks Quote
Moderators Robby Posted November 25, 2003 Moderators Posted November 25, 2003 you would have to remove the Like and the single quotes. sb.Append(dc.DataField + " = " + dc.FilterText ) Quote Visit...Bassic Software
SandyB Posted December 1, 2003 Author Posted December 1, 2003 Thanks, Robby. Sorry I haven't replied sooner. I was on vacation. Your solution works OK, except that I am filtering on keystrokes, so the data disappears until I get the entire number typed in. That's why I wanted to use "like". Quote
Moderators Robby Posted December 1, 2003 Moderators Posted December 1, 2003 I see what you're saying but I don't think that there's a way around it, except to change the columns' data type to strings. What you can do is use > (greater than) instead of = . Quote Visit...Bassic Software
SandyB Posted December 1, 2003 Author Posted December 1, 2003 I would think that there should be a way of saying, string representation of datafield like "*something*" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.