Click here to Skip to main content
15,910,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 9-May-11 1:46am
v2

1 solution

As Cost is a numeric field, should your filter not read
C#
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?
 
Share this answer
 
Comments
Sanyon_d 9-May-11 12:01pm    
Thanks for the reply. This didn't work for me. I used filterBs.Filter="Itemcode='1'". Then also didn't work. Do I need to implement this Filter method more.
Pete O'Hanlon 9-May-11 14:04pm    
Is ItemCode numeric?
Sanyon_d 9-May-11 23:01pm    
No. string

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900