NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataSetView Class

Represents a view of a DataSet with individual filters automatically set on each of its tables.

Object
   Component
      DataSetView

[Visual Basic]
Public Class DataSetView
   Inherits Component
   Implements IList, ICollection, IEnumerable, ITypedList
[C#]
public class DataSetView : Component, IList, ICollection,
   IEnumerable, ITypedList
[C++]
public __gc class DataSetView : public Component, IList,
   ICollection, IEnumerable, ITypedList
[JScript]
public class DataSetView extends Component, IList, ICollection,
   IEnumerable, ITypedList

Remarks

The DataSetView is an advanced feature of ADO+ that allows you to create multiple views of the same DataSet. This functionality allows you to create complex views of related tables where each table has a different filter, sort, state, and row state. For example, imagine a master/details view of a customers/orders relationship. The customers table is set to display only those customers whose names are "Smith." The orders table, on the other hand, shows only the orders (of the customers named "Smith") that have not yet shipped.

The steps to creating this scenario are as follows:

  1. Create and populate a DataSet.
  2. Create the DataSetView, passing the DataSet as an argument to the DataSetView.
  3. Add TableSetting objects to the TableSettingsCollection collection, one for each table in the DataSet.
  4. Bind the tables to appropriate controls (such as a ComboBox or a DataGrid control).

To bind a control to a DataSetView, determine if the control uses simple binding or complex binding. For example, a TextBox control can only be simple bound; a ComboBox, on the other hand, is complex bound.

To simple bind a TextBox control, access its BindingsCollection through its RichControl.Bindings property, and add a ListBinding to the collection.

To complex bind a ComboBox control, set its DataSource property to the DataSetView, and set the DisplayMember property to the DataTable and DataColumn to bind to. Use DataRelation objects to navigate from the parent table to its child table.

Requirements

Namespace: System.Data

Assembly: System.Data.dll

Example [Visual Basic]

The following example creates a DataSetView with a given DataSet, and adds two TableSetting objects to the TableSettingsCollection collection. A ComboBox and a DataGrid control are then bound to the DataSetView.

[Visual Basic]

' The next two lines go into the Declarations section of the module:
Private myDataSetView As DataSetView
' SuppliersProducts is a class derived from DataSet.
Private myDataSet As SuppliersProducts 

Private Sub CreateDataSetView()
   ' Not shown: SuppliersProducts is already configured with tables, relations, constraints.
   myDataSet = New SuppliersProducts
   myDataSetView = New DataSetView(myDataSet)
End Sub

Private Sub AddTableSettings()
   ' Create TableSetting and add it to TableSettingsCollection.
   Dim ts As TableSetting
   
   ts = New TableSetting(myDataSet.Tables("Suppliers"), "CompanyName", _
   "CompanyName < Z" & Combo1.Text, DataRowState.ModifiedCurrent)
   myDataSetView.TableSettings.Add(ts)

   ' Create and add second TableSetting.
   ts = New TableSetting(myDataSet.Tables("Products"), "ProductName", _
   "Discontinued = 'True'", DataRowState.CurrentRows)
   myDataSetView.TableSettings.Add(ts)
End Sub

Private Sub BindControls()
   ComboBox1.DataSource = myDataSetView
   ' Specify the table name and column name in the DisplayMember.
   ComboBox1.DisplayMember = "Suppliers.CompanyName"
   DataGrid1.DataSource = myDataSetView
   ' Specify the table to be viewed in the DataMember.
   DataGrid1.DataMember = "Products"
End Sub

See Also

DataSetView Members | System.Data Namespace | DataRelation | DataSet | DataView | TableSettingsCollection | TableSetting | BindingManager | BindingsCollection | ListBinding