473,804 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataView and DataViewRows

Joe
I have a DataView and would like to extract data from it and write it to a
ListView.

Can I only accomplish this with the DataViewRows Object array? Is there a
way forme to enumerate through the rows of the DataView without using the
DataViewRows array?

TIA,
--
Joe

VBA Automation/VB/C++/Web and DB development
Nov 16 '05 #1
6 10430
Joe,

You make me curious why, what can be shorter than something like this.

\\
DataView dv = new DataView(dt);
dv.Sort = "bla"; // sorts column bla
DataTable dtnew = dt.Clone();
foreach (DataRowView dvr in dv)
dtnew.ImportRow (dvr.Row);
dt.Clear();
dt = dtnew.Copy();
///
This sample that I made creates a sorted datatable, however should be usable
with a listview as well.

Cor

Nov 16 '05 #2
Hi,

What is wrong with the DataViewRows ?

in fact you dont even have to use it in a foreach , you can simnply do:
foreach( DataViewRow row in dataview_variab le)

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:80******** *************** ***********@mic rosoft.com...
I have a DataView and would like to extract data from it and write it to a
ListView.

Can I only accomplish this with the DataViewRows Object array? Is there a
way forme to enumerate through the rows of the DataView without using the
DataViewRows array?

TIA,
--
Joe

VBA Automation/VB/C++/Web and DB development

Nov 16 '05 #3
Joe
Please see response above.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

What is wrong with the DataViewRows ?

in fact you dont even have to use it in a foreach , you can simnply do:
foreach( DataViewRow row in dataview_variab le)

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:80******** *************** ***********@mic rosoft.com...
I have a DataView and would like to extract data from it and write it to a
ListView.

Can I only accomplish this with the DataViewRows Object array? Is there a
way forme to enumerate through the rows of the DataView without using the
DataViewRows array?

TIA,
--
Joe

VBA Automation/VB/C++/Web and DB development


Nov 16 '05 #4
Joe
Cor,

You answered my question. I have an app that creates a DataView from a
DataTable. Then I created a DataViewRows array and walked through the array
to retrieve its data. Clumsy, but it works.

Then I realized that this was inefficient, so I learned how to created a
DataView which only contained the data that I wanted. My question was how do
I enumerate through this DataView without creating another DataViewRows
array. The answer is below:

foreach (DataViewRow dvr in dv)
blah, blah, blah

Thanks!

"Cor Ligthert" wrote:
Joe,

You make me curious why, what can be shorter than something like this.

\\
DataView dv = new DataView(dt);
dv.Sort = "bla"; // sorts column bla
DataTable dtnew = dt.Clone();
foreach (DataRowView dvr in dv)
dtnew.ImportRow (dvr.Row);
dt.Clear();
dt = dtnew.Copy();
///
This sample that I made creates a sorted datatable, however should be usable
with a listview as well.

Cor

Nov 16 '05 #5
Joe:

One thing that important to realize is that the DataView does not, itself,
contain any data. A view is nothing more than a set of pointers
(references) to rows in the underlying DataTable. When you iterative over
this structure, you are acually following an ordered set of references and
pulling the data from the underlying DataTable structure.

John
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:80******** *************** ***********@mic rosoft.com...
I have a DataView and would like to extract data from it and write it to a
ListView.

Can I only accomplish this with the DataViewRows Object array? Is there a
way forme to enumerate through the rows of the DataView without using the
DataViewRows array?

TIA,
--
Joe

VBA Automation/VB/C++/Web and DB development

Nov 16 '05 #6
Joe
Thanks John. I appreciate the information.

"John Puopolo" wrote:
Joe:

One thing that important to realize is that the DataView does not, itself,
contain any data. A view is nothing more than a set of pointers
(references) to rows in the underlying DataTable. When you iterative over
this structure, you are acually following an ordered set of references and
pulling the data from the underlying DataTable structure.

John
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:80******** *************** ***********@mic rosoft.com...
I have a DataView and would like to extract data from it and write it to a
ListView.

Can I only accomplish this with the DataViewRows Object array? Is there a
way forme to enumerate through the rows of the DataView without using the
DataViewRows array?

TIA,
--
Joe

VBA Automation/VB/C++/Web and DB development


Nov 16 '05 #7

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

Similar topics

0
1588
by: RPI_alum | last post by:
I've been experiencing some frustrating behavior that I believe may be a MS bug in the Framework. Has anyone else experienced this, know a better way to resolve it, or if it is an actual MS bug *) I have a DataSet containing 2 tables, A and B *) There is a 1-to-1 relation between the tables with table A being the parent. (ABrel *) A DataView is created on table A to allow filtering of the result se *) 2 Text Boxes are created and Bound...
9
2589
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView 1. Simply defining the sort order and colum DataView...
2
3312
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
36
4485
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
13
2120
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...
5
8835
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it happen. Dim objKeys(2) as Object objKeys(0) = "CL" objKeys(2) = 4000 Dim posView As DataView = New DataView(posDS.Tables("Positions"), _
3
1622
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's relationship with the dataview). argh! company ---> person --->contact
5
3966
by: enceladus311 | last post by:
I'm trying to find a way to keep from having to fill a DataView after every PostBack to a page. Basically, the design is that I have a DataView that I fill, which I then set as the DataSource to a DataGrid on my page. This works well, however, like I said, I would like to keep from having to fill the DataView on each PostBack. So, naturally, what I did was checked whether or not the request was a PostBack by checking the IsPostBack...
0
2151
by: Pravin Pujari | last post by:
Hi All, I am using .net framework 1.1 and c#. I have one problem regarding dataview. I have one dataview to which sorting may be applied or may not be applied. I have one UI component where I am displaying the dataview. All rows in dataview are displayed in the sequence as they appear in dataview. i.e. there is direct mapping between dataview rows and UI rows. I have subscribed ColumnChanged event of the datatable on which dataview is...
0
9705
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
9576
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
10311
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,...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
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
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
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
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.