Wanted: Example of Row Filtering with DataView

S

Siegfried Heintze

I'm displaying information on job postings in various cities. For example,
might have a dozen jobs in Atlanta GA and I decide, at run time, that I
don't want to see them. How do I set my DataView to filter them out? I tried
but I don't understand the DataView.FilterState member function. Can someone
give me an example that works with a Datagrid and data set instead of a
console mode program?

Thanks,
Siegfried
 
G

Guest

Hi Siegfried,

Juan is right. You should use RowFilter. One thing should be mentioned is
that in RowFilter Expression, <> rather than != means NOT EQUAL. It follows
SQL syntax rather than C# syntax. Details please see following URL:
http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp

You mentioned FilterState. There isn’t FilterState for DataView. You might
mean RowStateFilter. It takes one value of DataViewRowState. You can take
look following URL:
http://msdn.microsoft.com/library/d...frlrfsystemdatadataviewrowstateclasstopic.asp

If you want to show result in a datagrid, after applying RowFilter property
to the dataview, assign the dataview to datagrid’s data:

Dv.RowFilter = Condition Expression (without WHERE);
Datagrid.DataSource = Dv;
Datagrid.DataBind();


HTH

Elton Wang
 
J

Juan T. Llibre

Hi, Elton.

re:
Juan is right. You should use RowFilter.

That makes a lot of sense... ;-)

re:
One thing should be mentioned is that in RowFilter Expression,
<> rather than != means NOT EQUAL. It follows SQL syntax
rather than C# syntax.

Good catch!

Thanks...



Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top