473,738 Members | 3,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataview.RowFil ter problem - displaying field value from first row


When I use the dataview.rowfil ter and I try to display the field value of
the first row, the code doesn't seem to show the first row AFTER the
rowfilter.
This is my code:

DataView DataView_Filter = new DataView();
DataView_Filter .Table = DS_States.Table s["Table1"];
sFilter = "Emplcode = '123233'";
DataView_Filter .RowFilter = sFilter;
MessageBox.Show (DataView_Filte r.Count.ToStrin g()); //it displays 6
items, which is correct.
MessageBox.Show (DataView_Filte r.Table.Rows[0]["Emplcode"].ToString());
//it displays the first item of the initial dataview, not the filtered
dataview

How can I display the first item of the filtered dataview? I assume there
must be some method that returns the array index since Rows[0] is not
necessarily the first row of the filtered dataview.

Jim
Nov 16 '05 #1
5 15817
Hi Jim,

Based on my understanding, you want to do the row filter through dataview
for your datatable.

After view your code, I find that your filter is correct, but you get the
filtered rows in an in-correct way.

After setting the RowFilter for DataView, you use DataView.Table property
to get the rows. If you view in MSDN, you will see that DataView.Table
property gets the source DataTable, which has nothing to do with filter(You
only filter the dataview not the underlying datatable). So you will get the
source datatable's first row.

Actually, you should do like this:

DataView dv_filter=new DataView();
dv_filter.Table =ds.Tables[0];
dv_filter.RowFi lter ="Emplcode = '123233'";
MessageBox.Show (dv_filter[0].Row["Emplcode"]);

=============== =============== ==
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2
Hi Jim,

Based on my understanding, you want to do the row filter through dataview
for your datatable.

After view your code, I find that your filter is correct, but you get the
filtered rows in an in-correct way.

After setting the RowFilter for DataView, you use DataView.Table property
to get the rows. If you view in MSDN, you will see that DataView.Table
property gets the source DataTable, which has nothing to do with filter(You
only filter the dataview not the underlying datatable). So you will get the
source datatable's first row.

Actually, you should do like this:

DataView dv_filter=new DataView();
dv_filter.Table =ds.Tables[0];
dv_filter.RowFi lter ="Emplcode = '123233'";
MessageBox.Show (dv_filter[0].Row["Emplcode"]);

=============== =============== ==
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #3
Hi Jim,

Have you tried my suggestion? Is your problem resolved?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #4
Hi Jim,

Have you tried my suggestion? Is your problem resolved?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #5
Hi,
I am having this similiar problem and I tried the approach that you
mentioned but it didn't work.
Jim Heimer wrote:
When I use the dataview.rowfil ter and I try to display the field value of the first row, the code doesn't seem to show the first row AFTER the
rowfilter.
This is my code:

DataView DataView_Filter = new DataView();
DataView_Filter .Table = DS_States.Table s["Table1"];
sFilter = "Emplcode = '123233'";
DataView_Filter .RowFilter = sFilter;
MessageBox.Show (DataView_Filte r.Count.ToStrin g()); //it displays 6 items, which is correct.
MessageBox.Show (DataView_Filte r.Table.Rows[0]["Emplcode"].ToString()); //it displays the first item of the initial dataview, not the filtered dataview

How can I display the first item of the filtered dataview? I assume there must be some method that returns the array index since Rows[0] is not
necessarily the first row of the filtered dataview.

Jim


Nov 16 '05 #6

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

Similar topics

4
522
by: Jim Heimer | last post by:
When I use the dataview.rowfilter and I try to display the field value of the first row, the code doesn't seem to show the first row AFTER the rowfilter. This is my code: DataView DataView_Filter = new DataView(); DataView_Filter.Table = DS_States.Tables; sFilter = "Emplcode = '123233'"; DataView_Filter.RowFilter = sFilter; MessageBox.Show (DataView_Filter.Count.ToString()); //it displays 6
3
3009
by: Siegfried Heintze | last post by:
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
8
3896
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
10
11165
by: Roy Lawson | last post by:
Can anyone explain the difference between RowStateFilter and RowFilter properties of the DataView objects in simple terms? I am going through a Transcender practice exam and just when I think I understand the difference I miss the question. Didn't pass the 306 exam two weeks ago and don't want to repeat that again <<scored 680, needed 700 :- ( >>
13
2113
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
14
9874
by: Able | last post by:
Dear friends Dim myDataView as DataView = New DataView(dsData.Tables("tblCustomers")) myDataView.RowFilter = "City = 'London'" My question is how to loop through all rows in myDataView and edit the field fldZipCode so fldZipCode = "9800" Regards Able
1
1598
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
I've been having an issue with an application that keeps track of applications that a client has by state and print this information from my ..net app to an excel file. I'm using a dataview to filter and sort the records so that I can print all of the Florida client together in column then all the North Carolina clients and so forth. So I have 3 columns (state, agency, and total) ; in order to prevent the list showing the state each time...
1
2711
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a global dataview is created -The user enters new part information into a form. -A function is called to check to see if the part is a new part (so that two identical part numbers are not added to the database. -The check is done by setting the...
5
11841
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a global dataview is created -The user enters new part information into a form. -A function is called to check to see if the part is a new part (so that two identical part numbers are not added to the database. -The check is done by setting the...
3
5392
by: =?Utf-8?B?cG1jZ3VpcmU=?= | last post by:
I have a dataset with 3 tables -- 2 Parent tables and 1 table that is a child table of both the parents. I create a dataview on the child table and set the rowfilter to a value which filters the child based on values in both parent tables. When I edit the parent tables the edit is not reflected in the dataview.count property. How can I force the dataview to refresh following parent table edits? For example: Parent1
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4569
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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 we have to send another system
2
2744
muto222
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.