我在对DataGridView应用RowFilter时遇到了问题。我确实需要使用IN和NOT IN来应用RowFilter。
示例:
custId in (select custId from loginDetails where date = '01/11/2010')注意:我的网格最初加载了CustMaster表中的所有客户详细信息。我需要的是过滤今天登录的客户的登录详细信息。Field custId也是动态的。
这是可能的吗?
如果有其他选择,请提供帮助。
发布于 2010-11-01 20:48:40
使用LINQ怎么样?
//1. Pick all of those that you do not want in your code.
//2. Select those that you want.
var result = from record in dtLoginDetails.AsEnumerable()
where //2. Select all records.
(!( //Remove the ! sign to use IN/NOT IN
(from custID in dtLoginDetails.AsEnumerable()
where custID.Field<string>("author").StartsWith("C") //1. Select those records that are unwanted.
//Note that, in your case you can add it like
//unwanted.Field<DateTime>("Date") = DateTime.Now.Date
select custID.Field<string>("author")
)
.Contains(record.Field<string>("author"))
)
)
select record;
//Cast as DataView
DataView view = result.AsDataView();发布于 2010-11-01 20:11:59
很多年前(.net v1),当"IN“所使用的表发生变化时,我遇到了视图不更新的问题。我不知道这个问题现在是否还存在于.net框架中。
https://stackoverflow.com/questions/4068433
复制相似问题