Tuesday, May 5, 2009

Explain DataView

A DataView enables us to create different views of the data stored in a DataTable, a capability that is often used in data-binding applications. Using a DataView, we can expose the data in a table with different sort orders, and we can filter the data by row state or based on a filter expression.

It provides a means to filter and sort data within a data table.

Example:
DataView myDataView = new DataView(myDataSet.Tables["Customers"]);

// Sort the view based on the FirstName column
myDataView.Sort = "CustomerID";

// Filter the dataview to only show customers with the CustomerID of XYZ
myDataView.RowFilter = "CustomerID=XYZ";

No comments:

Post a Comment