I am developing a datagridview filtering application. I am using the RowFilter property for dataview for filtering data. My database table contains fields of data types int and varchar. And I want to use the "LIKE" query in the RowFilter property to filter the dataview, but "LIKE" is used only for the string data type, and not for the int data type. Therefore, I want to convert a field of type int to a varchar data type, but I do not want to change the structure of the table. I just want the data type to be replaced by a temporary one only for my filter condition.
Can someone help me in solving this problem?
string colname="ProductID"; string condition="111"; DataView dv = new DataView(); dv.Table = ds.Tables[0] ; dv.RowFilter ="CAST ("+colname+" AS TEXT) LIKE '"+ condition+"%'" ;
source share