views:

351

answers:

2

I have a binding source and it has a column called Description and I want to exclude all rows that have their description set to 'x'.

I have tried:

bindingSource.Filter = "Description != ' + x;

That doesn't work. Does anyone know how to do a is not comparison for the binding source's filter? I couldn't find any help on MSDN.

+5  A: 

Try <> instead of !=.

See this for more help:

http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

Anton Gogolev
Reference to docs on this: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx
itsmatt
Filtering for binding sources and selecting on datasets works very much like it does in SQL. One thing to note is that if you are filtering on a datetime value, make sure you surround it with pound signs: string sFilter = "UpdateDTS > #" + DateTime.Now + "#";
bdwakefield
A: 

Try this:

bindingSource.Filter = String.Format("Description != '{0}'", x);

One other thing to try is using <> instead of != if the above does still not work.

Alexander Kahoun