我想在数据视图上应用行过滤器,它应该在列表上工作。下面是我到目前为止编写的代码,没有任何运气。
从源字符串中获取所有带有<% %>符号的标记。
string src = "<%Borrower Name%>|<%Dealer Number%>|<%Application Number%>|【<%Asset Make Description%>】尊敬的经销商:您提交的编号<%Application Number%>客户<%Borrower Name%>的申请已拒绝。";
MatchCollection matches = Regex.Matches(src, @"\<%([^%>]*)\%>");
List<string> lstnew = matches.Cast<Match>().Select(x => x.Value).ToList();
DataSet dstokens = new DataSet();
ReadTokensData(dstokens, null);下面是过滤部分,我想根据列表中的值过滤数据表,使用string[]进行此操作对我来说也是可以接受的。
dstokens.Tables["TOKENS_DATA"].DefaultView.RowFilter = "TOKEN_CAPTION IN (" + lstnew + ")";发布于 2017-03-24 06:38:04
试试这个
假设dtAllUsers数据表中包含数据。我们可以从dtAllUser的数据表中过滤数据,如下所示。
UserName =DataTable的列,您想在其中搜索
txt_SearchByUser.Text =要在UserName列中搜索的文本
dgv_All_Users =是一个DataGridView
DataView DV = new DataView(dtAllUsers);
DV.RowFilter = string.Format("UserName Like '%{0}%'",txt_SearchByUser.Text);
dgv_All_Users.DataSource = DV;发布于 2017-03-24 07:06:08
分解你的代码,它会导致;
WHERE TOEKN_CAPTION IN (<%BorrowerName%>,<%DealerNumber%>,<%AppNumber%>,etc)如你所愿
WHERE TOEKN_CAPTION IN ('BorrowerName','DealerNumber','AppNumber',etc)将Linq语句更改为
List<string> lstnew = matches.Cast<Match>().Select(x => x.Groups[1].Value).ToList();https://stackoverflow.com/questions/42992642
复制相似问题