PC Review


Reply
Thread Tools Rate Thread

DataView and DataViewRows

 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      7th Jan 2005
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
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      7th Jan 2005
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



 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      7th Jan 2005
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_variable)

Cheers,

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



"Joe" <(E-Mail Removed)> wrote in message
news:8043074C-1059-4457-BAA8-(E-Mail Removed)...
>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



 
Reply With Quote
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      7th Jan 2005
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
>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      7th Jan 2005
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_variable)
>
> Cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>
> "Joe" <(E-Mail Removed)> wrote in message
> news:8043074C-1059-4457-BAA8-(E-Mail Removed)...
> >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

>
>
>

 
Reply With Quote
 
John Puopolo
Guest
Posts: n/a
 
      7th Jan 2005
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" <(E-Mail Removed)> wrote in message
news:8043074C-1059-4457-BAA8-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      7th Jan 2005
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" <(E-Mail Removed)> wrote in message
> news:8043074C-1059-4457-BAA8-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted DataView, but unsorted datalist when bound to the dataview CodeMonkey Microsoft ASP .NET 1 4th Feb 2011 10:55 AM
to find the data from one dataview not in another dataview joe Microsoft ADO .NET 0 9th Jul 2008 10:39 AM
DataView - How to access the row in the datatable behind the DataView Richard Microsoft C# .NET 5 17th Jul 2005 04:57 PM
Is there an easy way to copy a DataView (or even the DataGrid showing the DataView) to the Clipboard? Kevin Brown Microsoft Dot NET 4 5th Jan 2005 09:01 PM
DataView.AddNew and DataView.Count =?Utf-8?B?c3VidA==?= Microsoft ADO .NET 5 21st Mar 2004 05:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:22 PM.