O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filter or Sort Data with a DataView

Problem

You want to show a subset of data from a DataTable or sort that data.

Solution

Set a filter or sort rows using the DataView.RowFilter and DataView.Sort properties.

Discussion

When you bind a DataTable to a Windows control, you’re actually making use of another type of object that acts as a mediator: the DataView. The DataView exposes the information from the DataTable and allows you to filter rows or apply a sort order.

You can create a DataView for a DataTable and bind the DataView to a control. However, it’s more common to bind controls directly to a DataTable. In this case, the DataView referenced by the DataTable.DefaultView property is used automatically. Thus, if you want to configure sorting or filtering, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required