本文介绍了Rowfilter替换功能选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不寻常的问题需要修复...我使用每个来循环通过职位名称并尝试将它们与我循环的另一个职位名称列表匹配。这个问题很奇怪 - 其中一个列表有时候很奇怪?字符而不是空格,特别是Chr(63)。理想情况下,我想在我的RowFilter表达式中使用替换函数。虽然这不可用,我看不到它的方法吗?



我想做点什么...



myDataView.RowFilter =JobRole.Replace('?','')='+ myString +';



任何人都可以建议我怎么做?谢谢。



我尝试了什么:



我试过更换我的匹配字符串与Chr(63)但没有运气。



myDataView.RowFilter =JobRole ='+ JobRoleDetails [Job Role]。ToString() .Trim()。替换(Strings.Chr(32),Strings.Chr(63))+';

Hi, I have an unusual problem to fix...I use a for each to loop through job titles and try and match them with another job title list that I cycle through. The issue is strange - one of the lists sometimes has a weird ? character instead of a space, specifically Chr(63). Ideally I would like to use a replace function in my RowFilter expression. This is not available though and I can't see a way around it?

I would like to do something like...

myDataView.RowFilter = "JobRole.Replace('?', ' ') = '" + myString + "'";

Can anybody please advise how I can do this? Thanks.

What I have tried:

I have tried replacing my matching string with a Chr(63) but no luck.

myDataView.RowFilter = "JobRole = '" + JobRoleDetails["Job Role"].ToString().Trim().Replace(Strings.Chr(32), Strings.Chr(63)) + "'";

推荐答案

DataTable dt = new DataTable();
            dt.Columns.Add("JobRole");
            dt.Rows.Add("Role 1");
            dt.Rows.Add("Role 2");
            dt.Rows.Add("Role? 3");
            dt.Rows.Add("Role 4");

            DataRow[] rows = dt.Select("JobRole like '%?%'");
            rows.ToList().ForEach(k => k["JobRole"] = (k["JobRole"] + "").Replace("?", " "));



这篇关于Rowfilter替换功能选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 02:21