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
>
>
>
>
|