DataView 允許您為儲存在 DataTable 內的資料建立不同的檢視,這是資料繫結應用程式中常用的功能。A DataView enables you to create different views of the data stored in a DataTable, a capability that is often used in data-binding applications. 您可以使用DataView,以不同的排序次序來公開資料表中的資料,而且您可以依資料列狀態或根據篩選運算式來篩選資料。Using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression.

DataView提供基礎DataTable中資料的動態視圖:內容、排序和成員資格會反映發生的變更。A DataView provides a dynamic view of data in the underlying DataTable: the content, ordering, and membership reflect changes as they occur. 此行為不同于DataTableDataRow Select方法,它會根據特定篩選和/或排序次序,從資料表傳回陣列:此內容反映基礎資料表的變更,但其成員資格和順序維持靜態。This behavior differs from the Select method of the DataTable, which returns a DataRow array from a table based on a particular filter and/or sort order: this content reflects changes to the underlying table, but its membership and ordering remain static. DataView的動態功能讓資料系結應用程式非常理想。The dynamic capabilities of the DataView make it ideal for data-binding applications.

DataView提供您單一資料集的動態觀點,與資料庫的觀點相似,您可以套用不同的排序和篩選準則。A DataView provides you with a dynamic view of a single set of data, much like a database view, to which you can apply different sorting and filtering criteria. 不過,不同于資料庫檢視, DataView無法被視為資料表,而且無法提供聯結資料表的觀點。Unlike a database view, however, a DataView cannot be treated as a table and cannot provide a view of joined tables. 此外,您也不能排除來源資料表中的資料行,也不能附加來源資料表中不存在的資料行 (如計算資料行)。You also cannot exclude columns that exist in the source table, nor can you append columns, such as computational columns, that do not exist in the source table.

您可以使用DataViewManager來管理資料集中所有資料表的視圖設定。You can use a DataViewManager to manage view settings for all the tables in a DataSet. DataViewManager提供便利的方式來管理每個資料表的預設 view 設定。The DataViewManager provides you with a convenient way to manage default view settings for each table. 將控制項系結至資料集的多個資料表時,系結至DataViewManager是理想的選擇。When binding a control to more than one table of a DataSet, binding to a DataViewManager is the ideal choice.

本節內容In This Section

建立 DataViewCreating a DataView
描述如何建立DataTableDataViewDescribes how to create a DataView for a DataTable.

排序和篩選資料Sorting and Filtering Data
描述如何設定DataView的屬性,以傳回符合特定篩選準則的資料列子集,或傳回特定排序次序的資料。Describes how to set the properties of a DataView to return subsets of data rows meeting specific filter criteria, or to return data in a particular sort order.

DataRow 和 DataRowViewDataRows and DataRowViews
描述如何存取DataView所公開的資料。Describes how to access the data exposed by the DataView.

尋找資料列Finding Rows
描述如何尋找DataView中的特定資料列。Describes how to find a particular row in a DataView.

子檢視和關聯ChildViews and Relations
描述如何使用DataView建立來自父子式關聯性的資料檢視。Describes how to create views of data from a parent-child relationship using a DataView.

修改 DataViewModifying DataViews
描述如何透過DataView修改基礎DataTable中的資料,包括啟用或停用更新。Describes how to modify the data in the underlying DataTable via the DataView, including enabling or disabling updates.

處理 DataView 事件Handling DataView Events
描述當DataView的內容或順序更新時,如何使用ListChanged事件來接收通知。Describes how to use the ListChanged event to receive notification when the contents or order of a DataView is being updated.

管理 DataViewManaging DataViews
描述如何使用DataViewManager來管理資料集內每個資料表的DataView設定。Describes how to use a DataViewManager to manage DataView settings for each table in a DataSet.

ASP.NET Web 應用程式ASP.NET Web Applications
提供 ASP.NET 應用程式、Web Form 和 Web 服務的建立概觀和詳細的步驟程序。Provides overviews and detailed, step-by-step procedures for creating ASP.NET applications, Web Forms, and Web Services.

Windows 應用程式Windows Applications
提供有關使用 Windows Form 和主控台應用程式的詳細資訊。Provides detailed information about working with Windows Forms and console applications.

DataSet、DataTable 和 DataViewDataSets, DataTables, and DataViews
描述DataSet物件,以及您可以如何使用它來管理應用程式資料。Describes the DataSet object and how you can use it to manage application data.

描述DataTable物件,以及如何使用它來管理應用程式資料本身,或做為資料集的一部分。Describes the DataTable object and how you can use it to manage application data by itself or as part of a DataSet.

說明 ADO.NET 的架構和元件,以及如何使用 ADO.NET 來存取現有資料來源和管理應用程式資料。Describes the ADO.NET architecture and components, and how to use ADO.NET to access existing data sources and manage application data.

另請參閱See also