473,473 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Wanted: Example of Row Filtering with DataView

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
Nov 19 '05 #1
3 2998
I think what you're looking for is RowFilter, not FilterState.

dataview1.RowFilter = "City != 'Atlanta'";

http://msdn.microsoft.com/library/de...ilterTopic.asp

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

"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:eg**************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2
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/de...ssiontopic.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/de...classtopic.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
"Siegfried Heintze" wrote:
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

Nov 19 '05 #3
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/
============================

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com... 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/de...ssiontopic.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/de...classtopic.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
"Siegfried Heintze" wrote:
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

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
2
by: Marco Ippolito | last post by:
I have an offline DataSet: id (PK, sorted ASC), firstname, enabled 1, Aaron, true 2, Bill, false 3, Charlie, true .... 10001, Mike, false 10002, Nathan, false
1
by: Jason | last post by:
I've gathered a bunch of data from Active Directory and placed it into a datatable ("ADTable"). I now need to sort and filter this table based on the selection of a drop down list("ddlCategory"). ...
3
by: Liddle Feesh | last post by:
Hi, I have a table named "Person" in a MSDE (2000) database, and am building a search form comprising of search fields on the top section (forename, surname, telephonenumber, etc) which all...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: LDD | last post by:
Hi Folks I'm trying to determine a way to handle paging, filtering and sorting in a datagrid. If I choose to filter and sort, I'd like to return a subset. If that resultset has more records...
2
by: Jason Huang | last post by:
Hi, I use the ReadXML method in my C# Windows Form project. Here is some of my C# code: xmlDS.ReadXml(curDir + "\\Dept.xml") ; There're 20 rows and 5 columns in the Dept.xml. But now I just...
2
by: Anup Daware | last post by:
Abstract: I want to filter a dataview with a value where column name have a SPACE. Description:- I bind a dataview to a datagrid, The query which is fetching the results in Dataset is something...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.