I have a DataView that I'm trying to filter based on a dynamic string:
dv.RowFilter = "ContentTitle = '" + titleFilter + "'";
In some cases, titleFilter
contains an apostrophe, which is closing out the filter query and causing an error.
Is there a way I can escape that character? I can't replace it.
Gets or sets the expression used to filter which rows are viewed in the DataView. public: virtual property System::String ^ RowFilter { System::String ^ get(); void set(System::String ^ value); };
Using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression. A DataView provides a dynamic view of data in the underlying DataTable: the content, ordering, and membership reflect changes as they occur.
Simply double the apostrophe (a.k.a. quote) inside the titleFilter
string with
dv.RowFilter = "ContentTitle = '" + titleFilter.Replace("'", "''") + "'";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With