Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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".

  • Moderators
Posted

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 = .

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...