DataTable.RowFilter 用法
/// <summary> /// 处理DataRow筛选条件的特殊字符 /// </summary> /// <param name="rowFilter">行筛选条件表达式</param> /// <returns></returns> public static string DvRowFilter(string rowFilter) { //在DataView的RowFilter里面的特殊字符要用"[]"括起来,单引号要换成"''",他的表达式里面没有通配符的说法 return rowFilter.Replace("[", "[[ ") .Replace("]", " ]]") .Replace("*", "[*]") .Replace("%", "[%]") .Replace("[[ ", "[[]") .Replace(" ]]", "[]]") .Replace("\'", "''"); }
dvData.RowFilter = string.Format(" {0}='{1}' ", field, CommUtils.DvRowFilter(rowData[field].ToString()));