绑定源未获得过滤器 [英] Binding Souce not getting filter
本文介绍了绑定源未获得过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码是这样的
My code is like this
BindingSource bs=new BindingSource();
List<items> lstItems= ListItems();
bs.DataSource=lstItems;
//I bind this bindingsouce to a gridview.
grd.DaataSource=bs;
//Then I copy this original BindingSource to a separate BindngSource
BindingSource filterBs=new BindingSource();
//Then I use a filter condition to Bindingsource
filterBs.Filter= "ItemCode=''1'' and cost>''200''";
grd.DataSource=null;
//Re binding the datasouce of the grid to the filtered bindingsource.
grd.DataSource=filterBs;</items>
但是现在它也显示了网格中的所有记录.
But now also it shows all records in the grid.
推荐答案
由于Cost是一个数字字段,因此您的过滤器不应读取
As Cost is a numeric field, should your filter not read
filter.Bs.Filter = "ItemCode = '1' AND cost > 200";
您为了将来更容易阅读,请在将来的代码块中输入您的代码?
Could you please enter your code in pre blocks in the future, to make it easier to read?
这篇关于绑定源未获得过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文