3

I would like to know the difference between DataView and DataRowView. I looked up on MSDN and it says the DataRowView is just a customized representation of DataView.

But can you also cast a DataView to DataRowView? Please explain

Many thanks

doglin
  • 1,651
  • 4
  • 28
  • 38

3 Answers3

5

A DataView is a subset of a DataTable, or a special "View" of it.

Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation. The DataView does not store data, but instead represents a connected view of its corresponding DataTable. Changes to the DataView’s data will affect the DataTable. Changes to the DataTable’s data will affect all DataViews associated with it.

A DataRowView is a row in the DataView, so it's a special "View" of a DataRow.

Represents a customized view of a DataRow.

The two are not the same thing.

The DataRowView object does have a Row property, which points it to the DataRow it represents. Likewise, the DataView object has a Table property, which points it to the DataTable it represents.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
4

A DataRowView is a DataRow from a DataView.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
2

MSDN says that a DataRowView is:

Represents a customized view of a DataRow.

So it is not referring to the DataView.

However the DataRowView is just a class used to represent a DataRow in the sort order applied to the DataView. In fact you could find between its properties the reference back to the DataRow

Steve
  • 213,761
  • 22
  • 232
  • 286