How can use RowFilter?

  • Thread starter Thread starter edgarjang
  • Start date Start date
E

edgarjang

I try to use one datatable and some rowfilters.
BUT I can not solve some problem.
please help me.
....
1. This sentence is good?
dataSet.Tables["PRODUCT"].DefaultView.RowFilter = "TYPE1 = '1' and 500 <
PRICE and PRICE < 1000"

2. Can you tell me the syntax of RowFilter(detail)

I will wait for your answer.
thank you.
 
The RowFilter property is very much like the "WHERE" clause in an SQL
statement. Each clause should consist of the Fieldname, an operation and a
value. Operators can be any of
<
<>
=
IN
LIKE

You can have multiple clauses separated with the AND keyword. Non-numeric
values should be enclosed in single quotes, dates should be enclosed in #
characters. The following example creates a new view from a specified table
and filters the rows then displays the results in a grid:-

DataView dv = new DataView(ds.Tables[0], "Index < 20");
dataGrid1.DataSource = dv;

Your second clause "500 < PRICE" should be reversed to be valid :- "PRICE >
500". Also you should create a new DataView as the DefaultView is Read-only.
If you look at the
DataColumn.Expression Property documentation in the help file it details the
functions which are also supported such as checking for nulls, getting the
length of a value etc.

Peter

--
Peter Foot
Windows Embedded MVP
In The Hand
http://www.inthehand.com

edgarjang said:
I try to use one datatable and some rowfilters.
BUT I can not solve some problem.
please help me.
...
1. This sentence is good?
dataSet.Tables["PRODUCT"].DefaultView.RowFilter = "TYPE1 = '1' and 500 <
PRICE and PRICE < 1000"

2. Can you tell me the syntax of RowFilter(detail)

I will wait for your answer.
thank you.
 
Back
Top