<\/script>')

Apostrophe in DataView RowFilter

I have a DataView that I am trying to filter based on a dynamic row:

dv.RowFilter = "ContentTitle = '" + titleFilter + "'"; 

In some cases, the titleFilter contains an apostrophe that closes the filter request and causes an error.

Is there any way to avoid this character? I can not replace it.

+5
source share
1 answer

Just add an apostrophe (aka quote) inside the titleFilter line using

 dv.RowFilter = "ContentTitle = '" + titleFilter.Replace("'", "''") + "'"; 
+11
source

Source: https://habr.com/ru/post/1479020/


All Articles