Rowfilter替换功能选项 [英] Rowfilter replace function options

查看:60
本文介绍了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)) + "'";

推荐答案

你应该试试这个



you shall try this

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("?", " "));


谢谢Karthik并为迟到的回复道歉。最终我在datarow级别更改了它但是我无法使用Replace?正如我在帖子中所说的那样。



这是我如何运作......

job = staff [Job Role] ;

asciiBytes = System.Text.Encoding.ASCII.GetBytes(job);

baO = new List< byte>();

foreach(asciiBytes中的字节bt)

{

//如果字符是63那么这是一个奇怪的问号所以用空格字符替换它

if(bt!= 63)

{

baO.Add(bt);

}

其他

baO.Add(32);

}



job = System.Text.Encoding.ASCII.GetString(baO.ToArray());
Thanks Karthik and apologies for the late reply. Ultimately I changed it at the datarow level however I couldn't use the Replace ? statement as I said in my post.

Here's how I got it working...
job = staff["Job Role"];
asciiBytes = System.Text.Encoding.ASCII.GetBytes(job);
baO = new List<byte>();
foreach (byte bt in asciiBytes)
{
//If the character is 63 then it's a weird question mark so replace it with a space character
if (bt != 63)
{
baO.Add(bt);
}
else
baO.Add(32);
}

job = System.Text.Encoding.ASCII.GetString(baO.ToArray());


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

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆