Hello. I have such a task: I have a gridcontrol and there is a DataTable, which for the grid is a DataSource. The table is a compilation of some data on travel. I want to add the ability to filter data. Suppose I have three combo boxes - users, trip status, city of departure. When you select a value in each box, the filter for the data set changes. Unfortunately, nothing smarter than about this option, I did not come up with:
DataView dv = new DataView(Tables.dtTrips); dv.RowFilter = (!string.IsNullOrEmpty(dv.RowFilter) ? dv.RowFilter + " and " : string.Empty) + "id_trip_state='" + id_state.ToString() + "'"; And such a code to change the value in each box. There can be a lot of filters, they can change, or they can be added after they are added. Accordingly, the question is whether the path is right. If it is correct, the second question - let's say we selected the user in the box, added a string to the filter "id_natural = '" + u_id.tostring () + "'". if you then change the user again, then the same line but with a different ID will simply add what is wrong. Accordingly, it was decided to use a regular expression that will find the value in single quotes after id_natural =, but as I did not try to write a regular schedule, I have not yet succeeded