Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数据视图,我试图根据动态字符串进行过滤:
dv.RowFilter = "ContentTitle = '" + titleFilter + "'";
在某些情况下,titleFilter包含一个撇号,它会关闭过滤器查询并导致错误。
titleFilter
有没有办法逃脱那个角色?我不能代替它。
titleFilter只需将字符串内的撇号(又名引号)加倍
dv.RowFilter = "ContentTitle = '" + titleFilter.Replace("'", "''") + "'";