Differncet

  • Thread starter Thread starter Sahil Malik [MVP]
  • Start date Start date
S

Sahil Malik [MVP]

DataView shows you a subset of a DataTable's data based upon a specified
condition/filter
DataView is a brand new object that holds references to only relevant
DataTable rows and the datatable itself.

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
Manida,

A dataview can be the in the datatable integrated defaultview or a new
representant of that called new dataview.

It holds information about which part of a datatable should be used (viewed)
by a rowfilter, and in which sequence it will be used (viewed) by the sort
property. As well has it some methods, by instance to find rows based on the
sort information.

I hope this helps,

Cor
 
In addition to Cor and Sahil - the 'difference' depends on who's point of
view you're looking from. The DataView is built on a DataTable like they
both mention. As such, from a User's point of view, there's NO difference.
There'd be absolutely no way, short of using Reflector or asking the
developer, for someone to tell that you bound something to a DataView vs a
DataTable or that any given data is in a DataView vs. DataTable.

I use views a lot more than tables when i'm displaying data b/c it often
needs sorted. And using the RowFilter to filter data is pretty simple to
employ (although you certainly can slice data with a DataTable.Select for
instance). For Aggregated values, the DataTable has the Compute Method
which lets you grab Sum, Count etc so often I bind to a view for display
purposes, but use Compute to provide summary statistics. When I'm using
NonVisual components, I almost never use a DataVIew b/c sorting isn't
typically necessary (although it certianly could be). So the datatable
gives you compute http://www.knowdotnet.com/articles/expressions.html
(which you can defeinitely mimick using a dataview but it's cleaner using a
DataTable) and DataViews give you sort.

All in all it's mainly a matter of personal preference. My rule of thumb is
that if I'm displyaing the data for the user, I'll bind to a View by
default - otherwise I just use a DataTable unless for some reason I need a
view.

HTH,

Bill
 
All in all it's mainly a matter of personal preference. My rule of thumb
is that if I'm displyaing the data for the user, I'll bind to a View by
default - otherwise I just use a DataTable unless for some reason I need a
view.
Right

As I do it to the defaultview in case if it is a complex control and direct
to the datatable if it is a simple control.

Cor
 
Good point. I got in the habit of doing it to a view across the board when
it's a UI thing, but you way definintely makes sense.
 
Back
Top